-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #344 from saleor/fix-build-workflow
Change CI/CD workflows
- Loading branch information
Showing
12 changed files
with
178 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "npm" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
|
||
jobs: | ||
release: | ||
if: ${{ github.event.label.name == 'release dev tag' }} | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
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 | ||
- 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 publish:ci-dev | ||
- 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 }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,98 +2,52 @@ name: QA | |
on: [pull_request] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
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 | ||
- name: Check linters | ||
run_install: | | ||
- args: [--frozen-lockfile] | ||
- name: Check linter | ||
run: pnpm lint | ||
- name: Check types | ||
run: pnpm check-types | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: pnpm/[email protected] | ||
with: | ||
version: 8.2.0 | ||
- uses: actions/setup-node@v3 | ||
- uses: actions/checkout@v4 | ||
- name: Setup PNPM | ||
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0 | ||
with: | ||
node-version: 18 | ||
cache: "pnpm" | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Test | ||
run_install: | | ||
- args: [--frozen-lockfile] | ||
- name: Run tests | ||
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 | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: pnpm/[email protected] | ||
- uses: actions/setup-node@v3 | ||
- uses: actions/checkout@v4 | ||
- name: Setup PNPM | ||
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0 | ||
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_install: | | ||
- args: [--frozen-lockfile] | ||
- name: Build package | ||
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 }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,30 +7,19 @@ 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 | ||
- name: Setup PNPM | ||
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0 | ||
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 | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,4 +116,4 @@ dist | |
.pnp.* | ||
|
||
.idea/ | ||
.vscode/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
pnpm run test:ci | ||
pnpm check-types && pnpm test:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.