From 8e9303aa46d44675293fddb8174d45c5350ce307 Mon Sep 17 00:00:00 2001 From: cte Date: Tue, 3 Jun 2025 14:37:01 -0700 Subject: [PATCH 1/3] DRY GHA workflows --- .github/actions/setup-node-pnpm/action.yml | 44 ++++++++++++ .github/workflows/changeset-release.yml | 16 +---- .github/workflows/code-qa.yml | 79 +++------------------- .github/workflows/marketplace-publish.yml | 15 +--- .github/workflows/nightly-publish.yml | 18 ++--- .github/workflows/update-contributors.yml | 25 ++----- 6 files changed, 69 insertions(+), 128 deletions(-) create mode 100644 .github/actions/setup-node-pnpm/action.yml diff --git a/.github/actions/setup-node-pnpm/action.yml b/.github/actions/setup-node-pnpm/action.yml new file mode 100644 index 0000000000..b26d292646 --- /dev/null +++ b/.github/actions/setup-node-pnpm/action.yml @@ -0,0 +1,44 @@ +name: "Setup Node.js and pnpm" +description: "Sets up Node.js and pnpm with caching and installs dependencies" + +inputs: + node-version: + description: "Node.js version to use" + required: false + default: "20.19.2" + pnpm-version: + description: "pnpm version to use" + required: false + default: "10.8.1" + skip-checkout: + description: "Skip checkout step if already done" + required: false + default: "false" + skip-install: + description: "Skip dependency installation" + required: false + default: "false" + install-args: + description: "Additional arguments for pnpm install" + required: false + default: "" + +runs: + using: "composite" + steps: + - name: Checkout code + if: ${{ inputs.skip-checkout != 'true' }} + uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: ${{ inputs.pnpm-version }} + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + cache: "pnpm" + - name: Install dependencies + if: ${{ inputs.skip-install != 'true' }} + shell: bash + run: pnpm install ${{ inputs.install-args }} diff --git a/.github/workflows/changeset-release.yml b/.github/workflows/changeset-release.yml index adbc5dc966..1b291abcb7 100644 --- a/.github/workflows/changeset-release.yml +++ b/.github/workflows/changeset-release.yml @@ -9,8 +9,6 @@ on: env: REPO_PATH: ${{ github.repository }} GIT_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || 'main' }} - NODE_VERSION: 20.19.2 - PNPM_VERSION: 10.8.1 jobs: # Job 1: Create version bump PR when changesets are merged to main @@ -31,18 +29,10 @@ jobs: with: fetch-depth: 0 ref: ${{ env.GIT_REF }} - - name: Install pnpm - uses: pnpm/action-setup@v4 + - name: Setup Node.js and pnpm + uses: ./.github/actions/setup-node-pnpm with: - version: ${{ env.PNPM_VERSION }} - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'pnpm' - - - name: Install Dependencies - run: pnpm install + skip-checkout: 'true' # Check if there are any new changesets to process - name: Check for changesets diff --git a/.github/workflows/code-qa.yml b/.github/workflows/code-qa.yml index ac378b65cd..766dfbb606 100644 --- a/.github/workflows/code-qa.yml +++ b/.github/workflows/code-qa.yml @@ -8,65 +8,28 @@ on: types: [opened, reopened, ready_for_review, synchronize] branches: [main] -env: - NODE_VERSION: 20.19.2 - PNPM_VERSION: 10.8.1 - jobs: check-translations: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'pnpm' - - name: Install dependencies - run: pnpm install + - name: Setup Node.js and pnpm + uses: ./.github/actions/setup-node-pnpm - name: Verify all translations are complete run: node scripts/find-missing-translations.js knip: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'pnpm' - - name: Install dependencies - run: pnpm install + - name: Setup Node.js and pnpm + uses: ./.github/actions/setup-node-pnpm - name: Run knip checks run: pnpm knip compile: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'pnpm' - - name: Install dependencies - run: pnpm install + - name: Setup Node.js and pnpm + uses: ./.github/actions/setup-node-pnpm - name: Lint run: pnpm lint - name: Check types @@ -78,19 +41,8 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'pnpm' - - name: Install dependencies - run: pnpm install + - name: Setup Node.js and pnpm + uses: ./.github/actions/setup-node-pnpm - name: Run unit tests run: pnpm test @@ -114,19 +66,8 @@ jobs: needs: [check-openrouter-api-key] if: needs.check-openrouter-api-key.outputs.exists == 'true' steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'pnpm' - - name: Install dependencies - run: pnpm install + - name: Setup Node.js and pnpm + uses: ./.github/actions/setup-node-pnpm - name: Create .env.local file working-directory: apps/vscode-e2e run: echo "OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY }}" > .env.local diff --git a/.github/workflows/marketplace-publish.yml b/.github/workflows/marketplace-publish.yml index 0719029e9d..5a88e61dc2 100644 --- a/.github/workflows/marketplace-publish.yml +++ b/.github/workflows/marketplace-publish.yml @@ -7,8 +7,6 @@ on: env: GIT_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || 'main' }} - NODE_VERSION: 20.19.2 - PNPM_VERSION: 10.8.1 jobs: publish-extension: @@ -25,17 +23,10 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ env.GIT_REF }} - - name: Install pnpm - uses: pnpm/action-setup@v4 + - name: Setup Node.js and pnpm + uses: ./.github/actions/setup-node-pnpm with: - version: ${{ env.PNPM_VERSION }} - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'pnpm' - - name: Install dependencies - run: pnpm install + skip-checkout: 'true' - name: Configure Git run: | git config user.name "github-actions[bot]" diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml index b7710f29d0..011d1df3f1 100644 --- a/.github/workflows/nightly-publish.yml +++ b/.github/workflows/nightly-publish.yml @@ -8,10 +8,6 @@ on: branches: [main] workflow_dispatch: # Allows manual triggering. -env: - NODE_VERSION: 20.19.2 - PNPM_VERSION: 10.8.1 - jobs: publish-nightly: runs-on: ubuntu-latest @@ -25,17 +21,11 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: Setup Node.js and pnpm + uses: ./.github/actions/setup-node-pnpm with: - node-version: ${{ env.NODE_VERSION }} - cache: 'pnpm' - - name: Install dependencies - run: pnpm install --frozen-lockfile + skip-checkout: 'true' + install-args: '--frozen-lockfile' - name: Forge numeric Nightly version id: version env: diff --git a/.github/workflows/update-contributors.yml b/.github/workflows/update-contributors.yml index d4e9768fb7..6ea74680ea 100644 --- a/.github/workflows/update-contributors.yml +++ b/.github/workflows/update-contributors.yml @@ -4,36 +4,21 @@ on: push: branches: - main - workflow_dispatch: # Allows manual triggering - -env: - NODE_VERSION: 20.19.2 - PNPM_VERSION: 10.8.1 + workflow_dispatch: jobs: update-contributors: runs-on: ubuntu-latest permissions: - contents: write # Needed for pushing changes - pull-requests: write # Needed for creating PRs + contents: write # Needed for pushing changes. + pull-requests: write # Needed for creating PRs. steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'pnpm' + - name: Setup Node.js and pnpm + uses: ./.github/actions/setup-node-pnpm - name: Disable Husky run: | echo "HUSKY=0" >> $GITHUB_ENV git config --global core.hooksPath /dev/null - - name: Install dependencies - run: pnpm install - name: Update contributors and format run: | pnpm update-contributors From f020e736ddcda3d035efff3c40536ed56534b0d8 Mon Sep 17 00:00:00 2001 From: cte Date: Tue, 3 Jun 2025 14:47:43 -0700 Subject: [PATCH 2/3] Trigger a new build --- .github/actions/setup-node-pnpm/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/setup-node-pnpm/action.yml b/.github/actions/setup-node-pnpm/action.yml index b26d292646..e9a022df47 100644 --- a/.github/actions/setup-node-pnpm/action.yml +++ b/.github/actions/setup-node-pnpm/action.yml @@ -1,4 +1,5 @@ name: "Setup Node.js and pnpm" + description: "Sets up Node.js and pnpm with caching and installs dependencies" inputs: From bb8058998f8517df7f8acfd5fb7f39445d88a644 Mon Sep 17 00:00:00 2001 From: cte Date: Tue, 3 Jun 2025 14:51:08 -0700 Subject: [PATCH 3/3] Fix --- .github/actions/setup-node-pnpm/action.yml | 7 ------- .github/workflows/code-qa.yml | 10 ++++++++++ .github/workflows/update-contributors.yml | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/actions/setup-node-pnpm/action.yml b/.github/actions/setup-node-pnpm/action.yml index e9a022df47..126d627245 100644 --- a/.github/actions/setup-node-pnpm/action.yml +++ b/.github/actions/setup-node-pnpm/action.yml @@ -11,10 +11,6 @@ inputs: description: "pnpm version to use" required: false default: "10.8.1" - skip-checkout: - description: "Skip checkout step if already done" - required: false - default: "false" skip-install: description: "Skip dependency installation" required: false @@ -27,9 +23,6 @@ inputs: runs: using: "composite" steps: - - name: Checkout code - if: ${{ inputs.skip-checkout != 'true' }} - uses: actions/checkout@v4 - name: Install pnpm uses: pnpm/action-setup@v4 with: diff --git a/.github/workflows/code-qa.yml b/.github/workflows/code-qa.yml index 766dfbb606..e34b0964ff 100644 --- a/.github/workflows/code-qa.yml +++ b/.github/workflows/code-qa.yml @@ -12,6 +12,8 @@ jobs: check-translations: runs-on: ubuntu-latest steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Setup Node.js and pnpm uses: ./.github/actions/setup-node-pnpm - name: Verify all translations are complete @@ -20,6 +22,8 @@ jobs: knip: runs-on: ubuntu-latest steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Setup Node.js and pnpm uses: ./.github/actions/setup-node-pnpm - name: Run knip checks @@ -28,6 +32,8 @@ jobs: compile: runs-on: ubuntu-latest steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Setup Node.js and pnpm uses: ./.github/actions/setup-node-pnpm - name: Lint @@ -41,6 +47,8 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Setup Node.js and pnpm uses: ./.github/actions/setup-node-pnpm - name: Run unit tests @@ -66,6 +74,8 @@ jobs: needs: [check-openrouter-api-key] if: needs.check-openrouter-api-key.outputs.exists == 'true' steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Setup Node.js and pnpm uses: ./.github/actions/setup-node-pnpm - name: Create .env.local file diff --git a/.github/workflows/update-contributors.yml b/.github/workflows/update-contributors.yml index 6ea74680ea..4dd36bfe29 100644 --- a/.github/workflows/update-contributors.yml +++ b/.github/workflows/update-contributors.yml @@ -13,6 +13,8 @@ jobs: contents: write # Needed for pushing changes. pull-requests: write # Needed for creating PRs. steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Setup Node.js and pnpm uses: ./.github/actions/setup-node-pnpm - name: Disable Husky