chore: Control concurrency of GitHub Actions jobs #1488
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
name: CI | |
on: | |
pull_request: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 0 * * 0' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
yarn_install: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Detect Yarn cache dir | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn config get cacheFolder)" | |
- name: Restore Yarn packages | |
id: yarn-restore | |
uses: actions/cache/restore@v3 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
# Restore node modules only if the SHA is perfect; to avoid possibility of corruption. | |
- name: Restore node_modules | |
id: node_modules-restore | |
uses: actions/cache/restore@v3 | |
with: | |
path: ./node_modules | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} | |
- name: Yarn install | |
if: steps.node_modules-restore.outputs.cache-hit != 'true' | |
run: yarn install | |
- name: Save Yarn packages | |
if: steps.node_modules-restore.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v3 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
- name: Save node_modules | |
if: steps.node_modules-restore.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v3 | |
with: | |
path: ./node_modules | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} | |
test_components: | |
runs-on: ubuntu-latest | |
needs: [yarn_install] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
# The storybook runner is going to do some Git operations that rely on access to the main branch. | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Setup Node | |
uses: ./.github/actions/setup-node | |
- name: Build | |
run: | | |
yarn workspaces foreach -v -t --exclude root --exclude @appland/appmap --exclude @appland/scanner run build | |
- name: Test | |
run: | | |
cd packages/components | |
yarn run lint | |
yarn run test | |
test_chromatic: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
needs: [yarn_install] | |
env: | |
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node | |
uses: ./.github/actions/setup-node | |
- name: Build | |
run: | | |
yarn workspaces foreach -v -t --exclude root --exclude @appland/appmap --exclude @appland/scanner run build | |
- name: Publish to Chromatic | |
uses: chromaui/action@latest | |
with: | |
workingDir: packages/components | |
test_cli: | |
runs-on: ubuntu-latest | |
needs: [yarn_install] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: ./.github/actions/setup-node | |
- name: Build | |
run: yarn run build | |
- name: Test | |
run: | | |
cd packages/cli | |
yarn run lint | |
yarn run test | |
test_scanner: | |
runs-on: ubuntu-latest | |
needs: [yarn_install] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: ./.github/actions/setup-node | |
- name: Build | |
run: | | |
yarn workspaces foreach -v -t --exclude root --exclude @appland/appmap --exclude @appland/components run build | |
- name: Test | |
run: | | |
cd packages/scanner | |
yarn run lint | |
yarn run test | |
test_native: | |
runs-on: ubuntu-latest | |
needs: [yarn_install] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: ./.github/actions/setup-node | |
- name: Setup Ruby | |
uses: actions/setup-ruby@v1 | |
with: | |
ruby-version: 3.1 | |
- name: Build | |
run: yarn run build | |
- name: Test | |
run: | | |
cd packages/cli | |
yarn test:binary | |
test_the_rest: | |
runs-on: ubuntu-latest | |
needs: [yarn_install] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: ./.github/actions/setup-node | |
- name: Build | |
run: | | |
yarn workspaces foreach -v -t --exclude root --exclude @appland/appmap --exclude @appland/components --exclude @appland/scanner run build | |
- name: Test | |
run: | | |
yarn workspaces foreach -v -t --exclude root --exclude @appland/appmap --exclude @appland/components --exclude @appland/scanner run lint | |
yarn workspaces foreach -v -t --exclude root --exclude @appland/appmap --exclude @appland/components --exclude @appland/scanner run test | |
release: | |
if: github.ref == 'refs/heads/main' | |
needs: | |
- test_cli | |
- test_components | |
- test_scanner | |
- test_native | |
- test_the_rest | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Setup Node | |
uses: ./.github/actions/setup-node | |
- name: Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
YARN_NPM_AUTH_TOKEN: ${{ secrets.YARN_NPM_AUTH_TOKEN }} | |
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
GIT_AUTHOR_NAME: appland-release | |
GIT_AUTHOR_EMAIL: [email protected] | |
GIT_COMMITTER_NAME: appland-release | |
GIT_COMMITTER_EMAIL: [email protected] | |
run: | | |
yarn | |
yarn build | |
yarn semantic-release | |
yarn chromatic --auto-accept-changes |