Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change CI/CD workflows #344

Merged
merged 31 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f82634f
test workflow
krzysztofzuraw Feb 29, 2024
090abc5
use full depth
krzysztofzuraw Feb 29, 2024
25d06f9
use full depth
krzysztofzuraw Feb 29, 2024
2168455
use orign main
krzysztofzuraw Feb 29, 2024
1c41d38
add echo
krzysztofzuraw Feb 29, 2024
8f88289
add has changesets
krzysztofzuraw Feb 29, 2024
ed41735
add cat
krzysztofzuraw Feb 29, 2024
3b1e336
test
krzysztofzuraw Feb 29, 2024
4a4a2be
test again
krzysztofzuraw Feb 29, 2024
9f637bc
test vol2
krzysztofzuraw Feb 29, 2024
9f7b1c9
add if
krzysztofzuraw Feb 29, 2024
1cf48e2
missing changesets
krzysztofzuraw Feb 29, 2024
950bb3a
add echo
krzysztofzuraw Feb 29, 2024
b0acefb
from json
krzysztofzuraw Feb 29, 2024
e99744d
check if true
krzysztofzuraw Feb 29, 2024
1bd5359
add test workflow
krzysztofzuraw Feb 29, 2024
f7487e6
add
krzysztofzuraw Feb 29, 2024
be9e977
test full workflow
krzysztofzuraw Feb 29, 2024
8432e9f
add version
krzysztofzuraw Feb 29, 2024
732e267
update workflows
krzysztofzuraw Feb 29, 2024
494120a
update changeset
krzysztofzuraw Feb 29, 2024
d4bd877
add dev release
krzysztofzuraw Mar 1, 2024
9c97e83
Merge branch 'main' into fix-build-workflow
krzysztofzuraw Mar 1, 2024
bbc784c
update workflows
krzysztofzuraw Mar 1, 2024
2dc90ee
test workflow
krzysztofzuraw Mar 1, 2024
0f3a3c9
last touches
krzysztofzuraw Mar 1, 2024
882ea12
remove changeset
krzysztofzuraw Mar 1, 2024
2ca385f
remove leftover
krzysztofzuraw Mar 1, 2024
44369a8
update check && dry run
krzysztofzuraw Mar 1, 2024
e7c359e
changes after CR
krzysztofzuraw Mar 1, 2024
c1b66b7
lint tsc error
krzysztofzuraw Mar 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/assign-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
jobs:
assign_creator:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Assign PR to creator
uses: thomaseizinger/[email protected].0
uses: toshimaru/auto-author-assign@ebd30f10fb56e46eb0759a14951f36991426fed0 # v2.1.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
48 changes: 48 additions & 0 deletions .github/workflows/dev-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release @dev tag to npm
on:
pull_request:
types: [labeled]
lkostrowski marked this conversation as resolved.
Show resolved Hide resolved

jobs:
release:
if: ${{ contains(github.event.pull_request.labels.*.name, 'release dev tag') }}
krzysztofzuraw marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
lkostrowski marked this conversation as resolved.
Show resolved Hide resolved
with:
fetch-depth: 0
- name: Setup PNPM
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
with:
run_install: |
- args: [--frozen-lockfile]
- name: Check for changeset
run: pnpm exec changeset status --since origin/main
lkostrowski marked this conversation as resolved.
Show resolved Hide resolved
- name: Build package
run: pnpm build
- name: Create .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release on @dev tag in npm
run: pnpm exec changeset version --snapshot pr && pnpm publish --tag dev --no-git-checks
- name: Get new package version
run: |
VERSION=$(cat package.json | jq -r '.version')
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Add installation instructions PR comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
env:
VERSION: ${{ env.VERSION }}
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Released snapshot build with `@dev` tag in npm with version: `${{ env.VERSION }}`.

Install it with:
```shell
pnpm add @saleor/app-sdk@${{ env.VERSION }}
```
88 changes: 9 additions & 79 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,99 +1,29 @@
name: QA
on: [pull_request]
jobs:
lint:
runs-on: ubuntu-latest
lint-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
- uses: actions/checkout@v4
- name: Setup PNPM
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
with:
version: 8.2.0
- uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm
- name: Install dependencies
run: pnpm install
run_install: |
- args: [--frozen-lockfile]
- name: Check linters
run: pnpm lint

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
with:
version: 8.2.0
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Test
run: pnpm test:ci
- name: Generate coverage report
uses: irongut/[email protected]
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
if: ${{ github.actor != 'dependabot[bot]' }}
with:
filename: coverage/cobertura-coverage.xml
format: markdown
output: file

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
with:
recreate: true
path: code-coverage-results.md

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
- uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm
- uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.json') }}-
- name: Install dependencies
run: pnpm install
- name: Build project
run: pnpm build
- name: Creating .npmrc
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release on @dev tag in npm
if: ${{ github.actor != 'dependabot[bot]' }}
run: npx changeset version --snapshot pr && pnpm publish --tag dev --no-git-checks
# Store package.json version in env
- run: echo "PACKAGE_JSON=$(jq -c . < package.json)" >> $GITHUB_ENV
if: ${{ github.actor != 'dependabot[bot]' }}
- run: echo '${{ fromJson(env.PACKAGE_JSON).version }}'
if: ${{ github.actor != 'dependabot[bot]' }}
# Post a comment with released snapshot
- name: Create with released tag
if: ${{ github.actor != 'dependabot[bot]' }}
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Released snapshot build with `@dev` tag in npm with version: `${{ fromJson(env.PACKAGE_JSON).version }}`

Install it with
```bash
pnpm add @saleor/app-sdk@${{ fromJson(env.PACKAGE_JSON).version }}
```
30 changes: 11 additions & 19 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,26 @@ on:

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

#
# TODO
# - Add tags for each app (e.g. [email protected]) for easier parsing
# - Print versions name to commit, for easier Vercel deployments
#
jobs:
release:
name: Prepare release with Changesets
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- uses: pnpm/[email protected] # Use version from package.json
- name: Setup Node.js 16 # It was default for Changesets action, check if it can be bumped to v18
uses: actions/setup-node@v3
- uses: actions/checkout@v4
with:
node-version: 16
- uses: pnpm/action-setup@v2
name: Install pnpm
- run: pnpm install
# TODO -> publish to npm as pre-release https://github.com/changesets/changesets/blob/8447c677a37d1d23858059e0ce2b5cd98f4c24ae/docs/snapshot-releases.md
token: ${{ secrets.PAT }}
- name: Setup PNPM
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
with:
run_install: |
- args: [--frozen-lockfile]
- name: Create Release Pull Request
uses: changesets/action@v1
id: changesets
uses: changesets/action@e2f8e964d080ae97c874b19e27b12e0a8620fb6c # v1.4.6
with:
title: Release to npm
commit: Release to npm
publish: "pnpm publish:ci"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Use private access token so Github can trigger another workflow from this one
GITHUB_TOKEN: ${{ secrets.PAT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ dist
.pnp.*

.idea/
.vscode/
.vscode/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"uuid": "9.0.0"
},
"devDependencies": {
"@changesets/cli": "2.26.2",
"@changesets/cli": "2.27.1",
"@testing-library/dom": "^8.17.1",
"@testing-library/react": "^13.4.0",
"@types/debug": "^4.1.7",
Expand Down
Loading
Loading