Skip to content

Commit 3cd074f

Browse files
Merge pull request #344 from saleor/fix-build-workflow
Change CI/CD workflows
2 parents dda3f6e + c1b66b7 commit 3cd074f

12 files changed

+178
-198
lines changed

.github/dependabot.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
version: 2
32
updates:
43
- package-ecosystem: "npm"

.github/workflows/assign-pr.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ on:
77
jobs:
88
assign_creator:
99
if: ${{ github.actor != 'dependabot[bot]' }}
10-
runs-on: ubuntu-latest
10+
runs-on: ubuntu-22.04
1111
steps:
1212
- name: Assign PR to creator
13-
uses: thomaseizinger/assign-pr-creator-action@v1.0.0
13+
uses: toshimaru/auto-author-assign@ebd30f10fb56e46eb0759a14951f36991426fed0 # v2.1.0
1414
with:
1515
repo-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/dev-release.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release @dev tag to npm
2+
on:
3+
pull_request:
4+
types: [labeled]
5+
6+
jobs:
7+
release:
8+
if: ${{ github.event.label.name == 'release dev tag' }}
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
- name: Setup PNPM
15+
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
16+
with:
17+
run_install: |
18+
- args: [--frozen-lockfile]
19+
- name: Check for changeset
20+
run: pnpm exec changeset status --since origin/main
21+
- name: Build package
22+
run: pnpm build
23+
- name: Create .npmrc
24+
run: |
25+
cat << EOF > "$HOME/.npmrc"
26+
//registry.npmjs.org/:_authToken=$NPM_TOKEN
27+
EOF
28+
env:
29+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
30+
- name: Release on @dev tag in npm
31+
run: pnpm publish:ci-dev
32+
- name: Get new package version
33+
run: |
34+
VERSION=$(cat package.json | jq -r '.version')
35+
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
36+
- name: Add installation instructions PR comment
37+
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
38+
env:
39+
VERSION: ${{ env.VERSION }}
40+
with:
41+
issue-number: ${{ github.event.pull_request.number }}
42+
body: |
43+
Released snapshot build with `@dev` tag in npm with version: `${{ env.VERSION }}`.
44+
45+
Install it with:
46+
```shell
47+
pnpm add @saleor/app-sdk@${{ env.VERSION }}
48+
```

.github/workflows/main.yml

+25-71
Original file line numberDiff line numberDiff line change
@@ -2,98 +2,52 @@ name: QA
22
on: [pull_request]
33
jobs:
44
lint:
5-
runs-on: ubuntu-latest
5+
runs-on: ubuntu-22.04
66
steps:
7-
- uses: actions/checkout@v3
8-
- uses: pnpm/action-setup@v2.2.4
7+
- uses: actions/checkout@v4
8+
- name: Setup PNPM
9+
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
910
with:
10-
version: 8.2.0
11-
- uses: actions/setup-node@v3
12-
with:
13-
node-version: 18
14-
cache: pnpm
15-
- name: Install dependencies
16-
run: pnpm install
17-
- name: Check linters
11+
run_install: |
12+
- args: [--frozen-lockfile]
13+
- name: Check linter
1814
run: pnpm lint
15+
- name: Check types
16+
run: pnpm check-types
1917

2018
test:
21-
runs-on: ubuntu-latest
19+
runs-on: ubuntu-22.04
2220
steps:
23-
- uses: actions/checkout@v3
24-
- uses: pnpm/action-setup@v2.2.4
25-
with:
26-
version: 8.2.0
27-
- uses: actions/setup-node@v3
21+
- uses: actions/checkout@v4
22+
- name: Setup PNPM
23+
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
2824
with:
29-
node-version: 18
30-
cache: "pnpm"
31-
- name: Install dependencies
32-
run: pnpm install
33-
- name: Test
25+
run_install: |
26+
- args: [--frozen-lockfile]
27+
- name: Run tests
3428
run: pnpm test:ci
3529
- name: Generate coverage report
36-
uses: irongut/CodeCoverageSummary@v1.3.0
30+
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
3731
if: ${{ github.actor != 'dependabot[bot]' }}
3832
with:
3933
filename: coverage/cobertura-coverage.xml
4034
format: markdown
4135
output: file
42-
4336
- name: Add Coverage PR Comment
44-
uses: marocchino/sticky-pull-request-comment@v2
37+
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
4538
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
4639
with:
4740
recreate: true
4841
path: code-coverage-results.md
4942

5043
build:
51-
runs-on: ubuntu-latest
44+
runs-on: ubuntu-22.04
5245
steps:
53-
- uses: actions/checkout@v3
54-
- uses: pnpm/action-setup@v2.2.4
55-
- uses: actions/setup-node@v3
46+
- uses: actions/checkout@v4
47+
- name: Setup PNPM
48+
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
5649
with:
57-
node-version: 18
58-
cache: pnpm
59-
- uses: actions/cache@v3
60-
with:
61-
path: |
62-
${{ github.workspace }}/.next/cache
63-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
64-
# If source files changed but packages didn't, rebuild from a prior cache.
65-
restore-keys: |
66-
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.json') }}-
67-
- name: Install dependencies
68-
run: pnpm install
69-
- name: Build project
50+
run_install: |
51+
- args: [--frozen-lockfile]
52+
- name: Build package
7053
run: pnpm build
71-
- name: Creating .npmrc
72-
if: ${{ github.actor != 'dependabot[bot]' }}
73-
run: |
74-
cat << EOF > "$HOME/.npmrc"
75-
//registry.npmjs.org/:_authToken=$NPM_TOKEN
76-
EOF
77-
env:
78-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
79-
- name: Release on @dev tag in npm
80-
if: ${{ github.actor != 'dependabot[bot]' }}
81-
run: npx changeset version --snapshot pr && pnpm publish --tag dev --no-git-checks
82-
# Store package.json version in env
83-
- run: echo "PACKAGE_JSON=$(jq -c . < package.json)" >> $GITHUB_ENV
84-
if: ${{ github.actor != 'dependabot[bot]' }}
85-
- run: echo '${{ fromJson(env.PACKAGE_JSON).version }}'
86-
if: ${{ github.actor != 'dependabot[bot]' }}
87-
# Post a comment with released snapshot
88-
- name: Create with released tag
89-
if: ${{ github.actor != 'dependabot[bot]' }}
90-
uses: peter-evans/create-or-update-comment@v2
91-
with:
92-
issue-number: ${{ github.event.pull_request.number }}
93-
body: |
94-
Released snapshot build with `@dev` tag in npm with version: `${{ fromJson(env.PACKAGE_JSON).version }}`
95-
96-
Install it with
97-
```bash
98-
pnpm add @saleor/app-sdk@${{ fromJson(env.PACKAGE_JSON).version }}
99-
```

.github/workflows/prepare-release.yml

+7-18
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,19 @@ on:
77

88
concurrency: ${{ github.workflow }}-${{ github.ref }}
99

10-
#
11-
# TODO
12-
# - Add tags for each app (e.g. search@3.0.1) for easier parsing
13-
# - Print versions name to commit, for easier Vercel deployments
14-
#
1510
jobs:
1611
release:
1712
name: Prepare release with Changesets
18-
runs-on: ubuntu-latest
13+
runs-on: ubuntu-22.04
1914
steps:
20-
- name: Checkout Repo
21-
uses: actions/checkout@v3
22-
- uses: pnpm/action-setup@v2.2.4 # Use version from package.json
23-
- name: Setup Node.js 16 # It was default for Changesets action, check if it can be bumped to v18
24-
uses: actions/setup-node@v3
15+
- uses: actions/checkout@v4
16+
- name: Setup PNPM
17+
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
2518
with:
26-
node-version: 16
27-
- uses: pnpm/action-setup@v2
28-
name: Install pnpm
29-
- run: pnpm install
30-
# TODO -> publish to npm as pre-release https://github.com/changesets/changesets/blob/8447c677a37d1d23858059e0ce2b5cd98f4c24ae/docs/snapshot-releases.md
19+
run_install: |
20+
- args: [--frozen-lockfile]
3121
- name: Create Release Pull Request
32-
uses: changesets/action@v1
33-
id: changesets
22+
uses: changesets/action@e2f8e964d080ae97c874b19e27b12e0a8620fb6c # v1.4.6
3423
with:
3524
title: Release to npm
3625
commit: Release to npm

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,4 @@ dist
116116
.pnp.*
117117

118118
.idea/
119-
.vscode/
119+
.vscode/

.husky/pre-push

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
pnpm run test:ci
4+
pnpm check-types && pnpm test:ci

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
"test": "vitest",
1111
"test:ci": "CI=true vitest --coverage --silent",
1212
"prepare": "husky install",
13-
"lint": "tsc --noEmit && prettier --loglevel warn --write . && eslint --fix .",
13+
"check-types": "tsc --noEmit",
14+
"lint": "prettier --loglevel warn --write . && eslint --fix .",
1415
"copy-readme": "cp README.md dist/README.md",
15-
"publish:ci": "pnpm publish && npx changeset tag && git push --follow-tags",
16+
"publish:ci-prod": "pnpm publish --dry-run",
17+
"publish:ci-dev": "pnpm publish --dry-run --tag dev",
1618
"lint-staged": "lint-staged"
1719
},
1820
"keywords": [],
@@ -35,7 +37,7 @@
3537
"uuid": "9.0.0"
3638
},
3739
"devDependencies": {
38-
"@changesets/cli": "2.26.2",
40+
"@changesets/cli": "2.27.1",
3941
"@testing-library/dom": "^8.17.1",
4042
"@testing-library/react": "^13.4.0",
4143
"@types/debug": "^4.1.7",

0 commit comments

Comments
 (0)