diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index 75dab9ec17..207b45851f 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -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 @@ -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 }} diff --git a/.github/actions/test/action.yaml b/.github/actions/test/action.yaml index cb954a9076..6b6a8fec31 100644 --- a/.github/actions/test/action.yaml +++ b/.github/actions/test/action.yaml @@ -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 }} diff --git a/.github/workflows/pr-build.yaml b/.github/workflows/pr-build.yaml deleted file mode 100644 index e514140b13..0000000000 --- a/.github/workflows/pr-build.yaml +++ /dev/null @@ -1,45 +0,0 @@ -name: Pull Request - Builds - -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 - - - name: Build packages - uses: ./.github/actions/build - with: - args: --affected diff --git a/.github/workflows/pr-test.yaml b/.github/workflows/pr-test.yaml deleted file mode 100644 index f17231ada5..0000000000 --- a/.github/workflows/pr-test.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: Pull Request - Tests - -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: - test: - name: Test with Node.js ${{ matrix.node-version }} - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [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 - - - name: Verify changesets - if: github.actor != 'janus-idp[bot]' - run: | - yarn changeset status --since=${{ github.event.pull_request.base.sha }} - - - name: Test packages - uses: ./.github/actions/test - with: - args: --affected diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 0000000000..4d4bdf819b --- /dev/null +++ b/.github/workflows/pr.yaml @@ -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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6b8d751a68..2329330997 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,12 +22,6 @@ 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 @@ -35,6 +29,11 @@ jobs: 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: @@ -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' diff --git a/.github/workflows/update-changeset-prs.yaml b/.github/workflows/update-changeset-prs.yaml new file mode 100644 index 0000000000..e8a844eee2 --- /dev/null +++ b/.github/workflows/update-changeset-prs.yaml @@ -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' diff --git a/package.json b/package.json index d6c7b7fa77..ffa268b917 100644 --- a/package.json +++ b/package.json @@ -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": [