From b7cd98da5467c1acbe557152ecd51481ed119c8e Mon Sep 17 00:00:00 2001 From: cte Date: Fri, 31 Jan 2025 21:44:50 -0800 Subject: [PATCH 1/5] Don't run the `integration-test` job if there's no API key --- .github/workflows/code-qa.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/code-qa.yml b/.github/workflows/code-qa.yml index f17a648..6f23421 100644 --- a/.github/workflows/code-qa.yml +++ b/.github/workflows/code-qa.yml @@ -44,6 +44,7 @@ jobs: run: npm test integration-test: + if: "${{ secrets.OPENROUTER_API_KEY != '' }}" strategy: matrix: os: [ubuntu-latest] # macos-latest, windows-latest From 17fb94cb1b3ee92228e0edc67b4a50cc01ac71fd Mon Sep 17 00:00:00 2001 From: cte Date: Fri, 31 Jan 2025 21:50:06 -0800 Subject: [PATCH 2/5] Secrets can't be used in conditionals, apparently --- .github/workflows/code-qa.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code-qa.yml b/.github/workflows/code-qa.yml index 6f23421..0ff0ff1 100644 --- a/.github/workflows/code-qa.yml +++ b/.github/workflows/code-qa.yml @@ -44,7 +44,10 @@ jobs: run: npm test integration-test: - if: "${{ secrets.OPENROUTER_API_KEY != '' }}" + # https://stackoverflow.com/questions/72925899/github-actions-detect-if-secret-exists + env: + OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} + if: ${{ env.OPENROUTER_API_KEY != '' }} strategy: matrix: os: [ubuntu-latest] # macos-latest, windows-latest @@ -59,8 +62,6 @@ jobs: cache: 'npm' - name: Create env.integration file run: echo "OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY }}" > .env.integration - - name: Check env.integration file - run: cat .env.integration - name: Install dependencies run: npm run install:all - run: xvfb-run -a npm run test:integration From de7f67f71ec7651ec61ded813377480c0dea40fb Mon Sep 17 00:00:00 2001 From: cte Date: Fri, 31 Jan 2025 22:03:33 -0800 Subject: [PATCH 3/5] One more attempt --- .github/workflows/code-qa.yml | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/code-qa.yml b/.github/workflows/code-qa.yml index 0ff0ff1..614db61 100644 --- a/.github/workflows/code-qa.yml +++ b/.github/workflows/code-qa.yml @@ -43,15 +43,25 @@ jobs: - name: Run unit tests run: npm test + check-openrouter-api-key: + runs-on: ubuntu-latest + outputs: + exists: ${{ steps.openrouter-api-key-check.outputs.defined }} + steps: + - name: Check if OPENROUTER_API_KEY exists + id: openrouter-api-key-check + shell: bash + run: | + if [ "${{ secrets.OPENROUTER_API_KEY }}" != '' ]; then + echo "defined=true" >> $GITHUB_OUTPUT; + else + echo "defined=false" >> $GITHUB_OUTPUT; + fi + integration-test: - # https://stackoverflow.com/questions/72925899/github-actions-detect-if-secret-exists - env: - OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} - if: ${{ env.OPENROUTER_API_KEY != '' }} - strategy: - matrix: - os: [ubuntu-latest] # macos-latest, windows-latest - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest + needs: [check-openrouter-api-key] + if: needs.check-openrouter-api-key.outputs.exists == 'true' steps: - name: Checkout code uses: actions/checkout@v4 @@ -64,7 +74,5 @@ jobs: run: echo "OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY }}" > .env.integration - name: Install dependencies run: npm run install:all - - run: xvfb-run -a npm run test:integration - if: runner.os == 'Linux' - - run: npm run test:integration - if: runner.os != 'Linux' + - name: Run integration tests + run: xvfb-run -a npm run test:integration From ab2dd09ac666e03bdb8c02fff775b244ad22afe6 Mon Sep 17 00:00:00 2001 From: cte Date: Fri, 31 Jan 2025 22:06:25 -0800 Subject: [PATCH 4/5] Test what happens if the secret does not exist --- .github/workflows/code-qa.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-qa.yml b/.github/workflows/code-qa.yml index 614db61..67ef540 100644 --- a/.github/workflows/code-qa.yml +++ b/.github/workflows/code-qa.yml @@ -48,11 +48,11 @@ jobs: outputs: exists: ${{ steps.openrouter-api-key-check.outputs.defined }} steps: - - name: Check if OPENROUTER_API_KEY exists + - name: Check if OpenRouter API key exists id: openrouter-api-key-check shell: bash run: | - if [ "${{ secrets.OPENROUTER_API_KEY }}" != '' ]; then + if [ "${{ secrets.XOPENROUTER_API_KEY }}" != '' ]; then echo "defined=true" >> $GITHUB_OUTPUT; else echo "defined=false" >> $GITHUB_OUTPUT; From 5c8df598897d48ddd1e60ef62314481203be6f38 Mon Sep 17 00:00:00 2001 From: cte Date: Fri, 31 Jan 2025 22:08:02 -0800 Subject: [PATCH 5/5] Confirmed that `check-openrouter-api-key` works; remove debugging --- .github/workflows/code-qa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-qa.yml b/.github/workflows/code-qa.yml index 67ef540..0636708 100644 --- a/.github/workflows/code-qa.yml +++ b/.github/workflows/code-qa.yml @@ -52,7 +52,7 @@ jobs: id: openrouter-api-key-check shell: bash run: | - if [ "${{ secrets.XOPENROUTER_API_KEY }}" != '' ]; then + if [ "${{ secrets.OPENROUTER_API_KEY }}" != '' ]; then echo "defined=true" >> $GITHUB_OUTPUT; else echo "defined=false" >> $GITHUB_OUTPUT;