Skip to content

Commit 6827ea3

Browse files
authored
Merge pull request #68 from DeskproApps/improve-local-dev
Improve local dev
2 parents ce7a1e8 + 1409928 commit 6827ea3

5 files changed

Lines changed: 168 additions & 165 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
{
2-
"name": "App Container",
3-
"image": "mcr.microsoft.com/devcontainers/javascript-node:latest",
4-
"features": {
5-
"ghcr.io/devcontainers/features/node:1": {
6-
"version": "lts",
7-
"pnpm": "latest"
8-
}
9-
},
10-
"customizations": {
11-
"vscode": {
12-
"settings": {
13-
"terminal.integrated.defaultProfile.linux": "bash",
14-
"editor.tabSize": 2
15-
},
16-
"extensions": [
17-
"dbaeumer.vscode-eslint"
18-
]
19-
}
20-
},
21-
"mounts": [
22-
"source=${localEnv:HOME}/.gitconfig,target=/home/node/.gitconfig,type=bind,consistency=cached",
23-
"source=${localEnv:HOME}/.ssh,target=/home/node/.ssh,type=bind,consistency=cached"
24-
],
25-
"postCreateCommand": "pnpm install"
26-
}
2+
"name": "App Container",
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node:latest",
4+
"features": {
5+
"ghcr.io/devcontainers/features/node:1": {
6+
"version": "lts",
7+
"pnpm": "latest"
8+
}
9+
},
10+
"customizations": {
11+
"vscode": {
12+
"settings": {
13+
"terminal.integrated.defaultProfile.linux": "bash",
14+
"editor.tabSize": 2
15+
},
16+
"extensions": [
17+
"dbaeumer.vscode-eslint"
18+
]
19+
}
20+
},
21+
"mounts": [
22+
"source=${localEnv:HOME}/.gitconfig,target=/home/node/.gitconfig,type=bind,consistency=cached",
23+
"source=${localEnv:HOME}/.ssh,target=/home/node/.ssh,type=bind,consistency=cached"
24+
],
25+
"postCreateCommand": "pnpm install",
26+
"containerEnv": {
27+
"npm_config_store_dir": "/home/node/.local/share/pnpm/store"
28+
}
29+
}

.github/workflows/branch_build.yml

Lines changed: 52 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -11,110 +11,75 @@ jobs:
1111
contents: write
1212
name: Test / Build
1313
timeout-minutes: 30
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
1717
- run: git fetch --no-tags --depth=1 origin master
1818

19-
- uses: actions/setup-node@v4
20-
with:
21-
node-version: "22"
22-
2319
- name: Clone repo
2420
uses: actions/checkout@v4
2521
with:
2622
fetch-depth: 0
2723

28-
- uses: pnpm/action-setup@v4
29-
name: Install pnpm
30-
id: pnpm-install
31-
with:
32-
version: 9
33-
run_install: false
34-
35-
- name: Get pnpm store directory
36-
id: pnpm-cache
37-
shell: bash
38-
run: |
39-
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
40-
- uses: actions/cache@v4
41-
name: Setup pnpm cache
42-
with:
43-
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
44-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
45-
restore-keys: |
46-
${{ runner.os }}-pnpm-store-
47-
- name: Install dependencies
48-
run: pnpm install --frozen-lockfile --strict-peer-dependencies
49-
50-
- name: Lint
51-
run: pnpm run lint
52-
53-
- name: Type check
54-
run: pnpm tsc --noemit
55-
56-
- name: Run tests
57-
run: pnpm test:coverage
58-
59-
- name: Get previous commit hash
60-
run: |
61-
PREV_COMMIT=$(git log -1 --pretty=format:%H -- manifest.json)
62-
echo "Previous commit hash is $PREV_COMMIT"
63-
id: get-commit-hash
64-
65-
- name: Get version number
66-
run: |
67-
VERSION=$(git show ${{ steps.get-commit-hash.outputs.PREV_COMMIT }}:manifest.json | grep version | awk -F'"' '{print $4}')
68-
echo "Version number is $VERSION"
69-
id: get-version
70-
71-
- name: Get version labels
72-
id: labels
73-
run: |
74-
commit_sha=$(git rev-parse HEAD)
75-
76-
pull_request_number=$(git log --format='%s' -n 1 | grep -oP '(?<=Merge pull request #)\d+' || true)
77-
78-
milestone=""
79-
80-
if [[ -n "$pull_request_number" ]]; then
81-
pull_request_info=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
82-
"https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${pull_request_number}")
83-
84-
milestone=$(echo "$pull_request_info" | jq -r '.labels[].name' | grep -E 'major-version|minor-version' | head -1)
85-
fi
86-
87-
echo "milestone=${milestone}" >> $GITHUB_OUTPUT
88-
89-
- name: Bump Version
24+
- name: Prep local dev
9025
run: |
91-
git config --global user.name "git log -1 --pretty=format:%an"
26+
touch ~/.gitconfig
27+
mkdir ~/.ssh
28+
git config --global user.name "$(git log -1 --pretty=format:%an)"
9229
git config --global user.email "$(git log -1 --pretty=format:%ae)"
9330
94-
if [ "$(git log -1 --pretty=format:%ae)" = "noreply@github.com" ]; then
95-
echo "Skipping workflow run because previous commit was not made by workflow."
96-
exit 0
97-
fi
98-
99-
if [[ "${{ steps.labels.outputs.milestone }}" == "major-version" ]]; then
100-
pnpm run bumpManifestVer major ${{ steps.get-version.outputs.VERSION }}
101-
elif [[ "${{ steps.labels.outputs.milestone }}" == "minor-version" ]]; then
102-
pnpm run bumpManifestVer minor ${{ steps.get-version.outputs.VERSION }}
103-
else
104-
pnpm run bumpManifestVer patch ${{ steps.get-version.outputs.VERSION }}
105-
fi
106-
107-
pnpm prettier --write manifest.json
31+
- name: Export PR Labels
32+
id: extract_labels
33+
run: echo "labels=$(jq -r '[.[] | .name] | join(",")' <<< '${{ toJson(github.event.pull_request.labels) }}')" >> $GITHUB_OUTPUT
10834

35+
- name: Lint, Test, Build, and Tag
36+
uses: devcontainers/ci@v0.3
37+
env:
38+
LABELS: "${{ steps.extract_labels.outputs.labels }}"
39+
with:
40+
env: LABELS
41+
runCmd: |
42+
set -e
43+
44+
# Lint
45+
pnpm run lint
46+
pnpm tsc --noemit
47+
48+
# Test
49+
pnpm test:coverage
50+
51+
# Build
52+
pnpm run build
53+
54+
# Tag
55+
if [ "$(git log -1 --pretty=format:%ae)" = "noreply@github.com" ]; then
56+
echo "Skipping workflow run because previous commit was made by workflow."
57+
exit 0
58+
fi
59+
60+
## Get current version number
61+
PREV_COMMIT=$(git log -1 --pretty=format:%H -- manifest.json)
62+
VERSION=$(git show $PREV_COMMIT:manifest.json | grep version | head -n 1 | awk -F'"' '{print $4}')
63+
## Get the commit message
64+
MILESTONE=$(echo "$LABELS" | grep -E 'major-version|minor-version' | head -1)
65+
66+
echo "Current Version is $VERSION and the milestone is $MILESTONE"
67+
if [[ "$MILESTONE" == "major-version" ]]; then
68+
pnpm run bumpManifestVer major $VERSION
69+
elif [[ "$MILESTONE" == "minor-version" ]]; then
70+
pnpm run bumpManifestVer minor $VERSION
71+
else
72+
pnpm run bumpManifestVer patch $VERSION
73+
fi
74+
75+
pnpm prettier --write manifest.json
76+
77+
- name: Update the Manifest in git
78+
run: |
10979
git add manifest.json
110-
11180
git commit -m "Updated Manifest"
112-
11381
git push origin master
11482
115-
- name: Build
116-
run: pnpm run build
117-
11883
- name: Package app zip
11984
working-directory: dist
12085
run: |
@@ -154,4 +119,3 @@ jobs:
154119
uses: DeskproApps/app-template-vite/.github/workflows/subworkflow-release.yml@master
155120
secrets: inherit
156121
needs: [deskpro_app_test_and_build]
157-

.github/workflows/pr_build.yml

Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,73 +9,70 @@ jobs:
99
deskpro_app_test_and_build:
1010
name: Test / Build
1111
timeout-minutes: 30
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4
1515
- run: git fetch --no-tags --depth=1 origin master
1616

17-
- uses: actions/setup-node@v4
18-
with:
19-
node-version: "22"
20-
2117
- name: Clone repo
2218
uses: actions/checkout@v4
2319
with:
2420
fetch-depth: 0
2521

26-
- uses: pnpm/action-setup@v4
27-
name: Install pnpm
28-
id: pnpm-install
29-
with:
30-
version: 9
31-
run_install: false
32-
33-
- name: Get pnpm store directory
34-
id: pnpm-cache
35-
shell: bash
22+
- name: Prep local dev
3623
run: |
37-
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
38-
- uses: actions/cache@v4
39-
name: Setup pnpm cache
24+
touch ~/.gitconfig
25+
mkdir ~/.ssh
26+
git config --global user.name "$(git log -1 --pretty=format:%an)"
27+
git config --global user.email "$(git log -1 --pretty=format:%ae)"
28+
29+
- name: Export PR Labels
30+
id: extract_labels
31+
run: echo "labels=$(jq -r '[.[] | .name] | join(",")' <<< '${{ toJson(github.event.pull_request.labels) }}')" >> $GITHUB_OUTPUT
32+
33+
- name: Lint, Test, Build, and Tag
34+
uses: devcontainers/ci@v0.3
35+
env:
36+
LABELS: "${{ steps.extract_labels.outputs.labels }}"
4037
with:
41-
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
42-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
43-
restore-keys: |
44-
${{ runner.os }}-pnpm-store-
45-
- name: Install dependencies
46-
run: pnpm install --frozen-lockfile --strict-peer-dependencies
38+
env: LABELS
39+
runCmd: |
40+
set -e
4741
48-
- name: Lint
49-
run: pnpm run lint
42+
# Lint
43+
pnpm run lint
44+
pnpm tsc --noemit
5045
51-
- name: Type check
52-
run: pnpm tsc --noemit
46+
# Test
47+
pnpm test:coverage
5348
54-
- name: Run tests
55-
run: pnpm test:coverage
49+
# Build
50+
pnpm run build
5651
57-
- name: Get labels from pull request
58-
id: labels
59-
run: echo "milestone=$(jq --raw-output '.pull_request.labels[].name' $GITHUB_EVENT_PATH | grep -E 'major-version|minor-version' | head -1)" >> $GITHUB_OUTPUT
52+
# Tag
53+
if [ "$(git log -1 --pretty=format:%ae)" = "noreply@github.com" ]; then
54+
echo "Skipping workflow run because previous commit was made by workflow."
55+
exit 0
56+
fi
57+
58+
## Get current version number
59+
PREV_COMMIT=$(git log -1 --pretty=format:%H -- manifest.json)
60+
VERSION=$(git show $PREV_COMMIT:manifest.json | grep version | head -n 1 | awk -F'"' '{print $4}')
61+
62+
## Get the commit message
63+
MILESTONE=$(echo "$LABELS" | grep -E 'major-version|minor-version' | head -1)
64+
65+
echo "Current Version is $VERSION and the milestone is $MILESTONE"
66+
if [[ "$MILESTONE" == "major-version" ]]; then
67+
pnpm run bumpManifestVer major $VERSION
68+
elif [[ "$MILESTONE" == "minor-version" ]]; then
69+
pnpm run bumpManifestVer minor $VERSION
70+
else
71+
pnpm run bumpManifestVer patch $VERSION
72+
fi
73+
74+
pnpm prettier --write manifest.json
6075
61-
- name: Bump Version
62-
run: |
63-
git config --global user.name "git log -1 --pretty=format:%an"
64-
git config --global user.email "$(git log -1 --pretty=format:%ae)"
65-
if [ "$(git log -1 --pretty=format:%ae)" = "noreply@github.com" ]; then
66-
echo "Skipping workflow run because previous commit was not made by workflow."
67-
exit 0
68-
fi
69-
if [[ "${{ steps.labels.outputs.milestone }}" == "major-version" ]]; then
70-
pnpm run bumpManifestVer major
71-
elif [[ "${{ steps.labels.outputs.milestone }}" == "minor-version" ]]; then
72-
pnpm run bumpManifestVer minor
73-
else
74-
pnpm run bumpManifestVer
75-
fi
76-
77-
- name: Build
78-
run: pnpm run build
7976
- name: Package app zip
8077
working-directory: dist
8178
run: |
@@ -88,7 +85,7 @@ jobs:
8885
path: |
8986
dist/app.zip
9087
dist/manifest.json
91-
retention-days: 1
88+
retention-days: 7
9289

9390
deploy:
9491
uses: DeskproApps/app-template-vite/.github/workflows/subworkflow-deploy.yml@master

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Launch Server",
8+
"runtimeExecutable": "pnpm",
9+
"runtimeArgs": ["start"],
10+
"skipFiles": ["<node_internals>/**"],
11+
"console": "integratedTerminal"
12+
}
13+
]
14+
}

.vscode/tasks.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "shell",
6+
"command": "pnpm build:package",
7+
"group": {
8+
"kind": "build",
9+
"isDefault": true
10+
},
11+
"problemMatcher": [],
12+
"label": "pnpm: build:package"
13+
},
14+
{
15+
"type": "shell",
16+
"command": "pnpm test",
17+
"group": {
18+
"kind": "test",
19+
"isDefault": true
20+
},
21+
"problemMatcher": [],
22+
"label": "pnpm: test"
23+
}
24+
]
25+
}

0 commit comments

Comments
 (0)