Skip to content

Commit b81bb86

Browse files
Skip tests that require secrets in forks (#495)
We know that forks won't have our secrets, so we separate those toolkits out to new a new test group and skip them if you aren't in this main repo. We know if a test suite has a secret via a magic comment --------- Co-authored-by: Eric Gustin <34000337+EricGustin@users.noreply.github.com>
1 parent 856606f commit b81bb86

File tree

1 file changed

+50
-6
lines changed

1 file changed

+50
-6
lines changed

.github/workflows/test-toolkits.yml

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,31 @@ jobs:
1111
setup:
1212
runs-on: ubuntu-latest
1313
outputs:
14-
tool_matrix: ${{ steps.get-toolkits.outputs.toolkits }}
14+
toolkits_with_gha_secrets: ${{ steps.load_toolkits.outputs.toolkits_with_gha_secrets }}
15+
toolkits_without_gha_secrets: ${{ steps.load_toolkits.outputs.toolkits_without_gha_secrets }}
1516
steps:
1617
- name: Check out
1718
uses: actions/checkout@v4
1819

19-
- name: Get toolkits
20-
id: get-toolkits
20+
- name: determine toolkits with and without GHA secrets
21+
id: load_toolkits
2122
run: |
2223
# Find all directories in toolkits/ that have a pyproject.toml
2324
TOOLKITS=$(find toolkits -maxdepth 1 -type d -not -name "toolkits" -exec test -f {}/pyproject.toml \; -exec basename {} \; | jq -R -s -c 'split("\n")[:-1]')
25+
TOOLKITS_WITH_GHA_SECRETS='["postgres"]'
26+
TOOLKITS_WITHOUT_GHA_SECRETS=$(echo "$TOOLKITS" | jq -c --argjson with "$TOOLKITS_WITH_GHA_SECRETS" '[.[] | select(. as $t | $with | index($t) | not)]')
2427
echo "Found toolkits: $TOOLKITS"
25-
echo "toolkits=$TOOLKITS" >> $GITHUB_OUTPUT
28+
echo "Found toolkits without GHA secrets: $TOOLKITS_WITHOUT_GHA_SECRETS"
29+
echo "Found toolkits with GHA secrets: $TOOLKITS_WITH_GHA_SECRETS"
30+
echo "toolkits_without_gha_secrets=$TOOLKITS_WITHOUT_GHA_SECRETS" >> $GITHUB_OUTPUT
31+
echo "toolkits_with_gha_secrets=$TOOLKITS_WITH_GHA_SECRETS" >> $GITHUB_OUTPUT
2632
2733
test-toolkits:
2834
needs: setup
2935
runs-on: ubuntu-latest
3036
strategy:
3137
matrix:
32-
toolkit: ${{ fromJson(needs.setup.outputs.tool_matrix) }}
38+
toolkit: ${{ fromJson(needs.setup.outputs.toolkits_without_gha_secrets) }}
3339
fail-fast: true
3440
steps:
3541
- name: Check out
@@ -48,7 +54,45 @@ jobs:
4854
uv run --active pre-commit run -a
4955
uv run --active mypy --config-file=pyproject.toml
5056
51-
- name: Test toolkit
57+
- name: Test stand-alone toolkits (no secrets)
58+
working-directory: toolkits/${{ matrix.toolkit }}
59+
run: |
60+
# Run pytest and capture exit code
61+
uv run --active pytest -W ignore -v --cov=arcade_${{ matrix.toolkit }} --cov-report=xml || EXIT_CODE=$?
62+
63+
if [ "${EXIT_CODE:-0}" -eq 5 ]; then
64+
echo "No tests found for toolkit ${{ matrix.toolkit }}, skipping..."
65+
exit 0
66+
elif [ "${EXIT_CODE:-0}" -ne 0 ]; then
67+
exit ${EXIT_CODE}
68+
fi
69+
70+
test-toolkits-with-gha-secrets:
71+
needs: setup
72+
runs-on: ubuntu-latest
73+
strategy:
74+
matrix:
75+
toolkit: ${{ fromJson(needs.setup.outputs.toolkits_with_gha_secrets) }}
76+
fail-fast: true
77+
steps:
78+
- name: Check out
79+
uses: actions/checkout@v4
80+
81+
- name: Set up the environment
82+
uses: ./.github/actions/setup-uv-env
83+
84+
- name: Install toolkit dependencies
85+
working-directory: toolkits/${{ matrix.toolkit }}
86+
run: uv pip install -e ".[dev]"
87+
88+
- name: Check toolkit
89+
working-directory: toolkits/${{ matrix.toolkit }}
90+
run: |
91+
uv run --active pre-commit run -a
92+
uv run --active mypy --config-file=pyproject.toml
93+
94+
- name: Test stand-alone toolkits (with secrets)
95+
if: github.repository == 'ArcadeAI/arcade-ai'
5296
working-directory: toolkits/${{ matrix.toolkit }}
5397
env:
5498
TEST_POSTGRES_DATABASE_CONNECTION_STRING: ${{ secrets.TEST_POSTGRES_DATABASE_CONNECTION_STRING }} # TODO: dynamically only load the `TEST_${{ matrix.toolkit }}_DATABASE_CONNECTION_STRING secret`

0 commit comments

Comments
 (0)