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

chore(ci): backport ci changes to 1.3 #2425

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Build all packages
description: Build all packages
name: Build packages
description: Build packages
inputs:
args:
description: Backstage CLI repo build arguments
Expand All @@ -8,6 +8,7 @@ inputs:
runs:
using: 'composite'
steps:
- name: Build all packages
- name: Build packages
shell: bash
run: yarn run build ${{ inputs.args }}
run: |
yarn run build --concurrency=75% ${{ inputs.args }}
7 changes: 3 additions & 4 deletions .github/actions/test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ runs:
echo
exit 42
fi
- name: Run prettier
shell: bash
run: yarn prettier:check ${{ inputs.args }}
run: yarn prettier:check --concurrency=75% ${{ inputs.args }}

- name: Run lint
shell: bash
run: yarn run lint:check ${{ inputs.args }}
run: yarn run lint:check --concurrency=75% ${{ inputs.args }}

- name: Run tests
shell: bash
run: yarn run test ${{ inputs.args }}
run: yarn run test --concurrency=75% ${{ inputs.args }}
45 changes: 0 additions & 45 deletions .github/workflows/pr-build.yaml

This file was deleted.

50 changes: 0 additions & 50 deletions .github/workflows/pr-test.yaml

This file was deleted.

85 changes: 85 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Pull Request

on: pull_request

env:
TURBO_SCM_BASE: ${{ github.event.pull_request.base.sha }}
TURBO_SCM_HEAD: ${{ github.sha }}

# enforce only one action can run at a time for a given PR, and
# when updating a PR, actions in progress will be cancelled to start a fresh one
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build with Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'

- name: Setup local Turbo cache
uses: dtinth/setup-github-actions-caching-for-turbo@cc723b4600e40a6b8815b65701d8614b91e2669e # v1

- name: Install dependencies
run: |
yarn install --frozen-lockfile

- name: Build packages
uses: ./.github/actions/build
with:
args: --affected

test:
name: Test with Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'

- name: Setup local Turbo cache
uses: dtinth/setup-github-actions-caching-for-turbo@cc723b4600e40a6b8815b65701d8614b91e2669e # v1

- name: Install dependencies
run: |
yarn install --frozen-lockfile

- name: Verify changesets
run: |
echo "Working in branch ${{ github.ref_name }}"
if [[ "${{ github.ref_name }}" != *"changeset-release/"* ]]; then
echo "Check changeset status since ${{ github.event.pull_request.base.sha }}"
yarn changeset status --since=${{ github.event.pull_request.base.sha }}
else
echo "Skipped - changeset-release/* PR"
fi
- name: Test packages
uses: ./.github/actions/test
with:
args: --affected
16 changes: 9 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@ jobs:
name: Release Packages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
# don't persist the GITHUB_TOKEN so the release can use use the generated token
persist-credentials: false

- name: Generate token
id: generate-token
uses: actions/create-github-app-token@31c86eb3b33c9b601a1f60f98dcbfd1d70f379b4 # v1.10.3
with:
app-id: ${{ vars.JANUS_IDP_GITHUB_APP_ID }}
private-key: ${{ secrets.JANUS_IDP_GITHUB_APP_PRIVATE_KEY }}

- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
token: ${{ steps.generate-token.outputs.token }}

- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
Expand All @@ -60,9 +59,12 @@ jobs:
with:
title: 'chore(release): version packages on ${{ github.ref_name }} branch'
commit: 'chore(release): version packages on ${{ github.ref_name }} branch'
# We want to make sure an update-to-date yarn lockfile is committed
version: yarn run packages:version
publish: yarn run packages:publish
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# we used to set 8G here but since the process often craps out, let's try 14G!
# https://stackoverflow.com/questions/48387040/how-do-i-determine-the-correct-max-old-space-size-for-node-js
NODE_OPTIONS: '--max-old-space-size=14336'
66 changes: 66 additions & 0 deletions .github/workflows/update-changeset-prs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Update changeset PRs

on:
push:
branches:
- 'changeset-release/**'

# enforce only one release action per release branch at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
prev-commit:
name: Verify previous commit
runs-on: ubuntu-latest
outputs:
valid: ${{ steps.prev-commit.outputs.valid }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

# We do not want an infinite loop; therefore, we are checking if the previous
# commit was created by this action.
- name: Get previous commit message
id: prev-commit
run: |
echo "valid=$(if [[ $(git log -1 --pretty=%B HEAD) != 'chore: update yarn.lock' ]]; then echo 'true'; else echo 'false'; fi)" >> $GITHUB_OUTPUT

update-and-commit-files:
name: Update and commit files
needs: prev-commit
if: needs.prev-commit.outputs.valid == 'true'
runs-on: ubuntu-latest

steps:
- name: Generate token
id: generate-token
uses: actions/create-github-app-token@31c86eb3b33c9b601a1f60f98dcbfd1d70f379b4 # v1.10.3
with:
app-id: ${{ vars.JANUS_IDP_GITHUB_APP_ID }}
private-key: ${{ secrets.JANUS_IDP_GITHUB_APP_PRIVATE_KEY }}

- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
token: ${{ steps.generate-token.outputs.token }}

- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
# We want to commit the yarn.lock changes
run: yarn install

- name: Clean export dynamic
# We want a clean dynamic folder
run: yarn run export-dynamic:clean --concurrency=75% --affected

- name: Amend previous commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'chore: update yarn.lock'
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"export-dynamic": "turbo run export-dynamic",
"export-dynamic:clean": "turbo run export-dynamic:clean",
"versions:bump": "backstage-cli versions:bump && find . -name 'package.json' ! -path '*/node_modules/*' -exec sed -i -e '/devDependencies/,/\\\\}/{ s/\\\"\\\\^/\\\"/; }' {} ; && yarn install && turbo run export-dynamic:clean",
"packages:version": "changeset version && yarn install && turbo run export-dynamic:clean --concurrency=75% --affected && git add .\\*package.json .\\*yarn.lock",
"packages:publish": "turbo run build --concurrency=75% --filter=@janus-idp/* && changeset publish"
"packages:version": "changeset version",
"packages:publish": "turbo run build --concurrency=75% --filter='@janus-idp/*' && changeset publish"
},
"workspaces": {
"packages": [
Expand Down
Loading