Optimize Test Sharding #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Optimize Test Sharding | |
| on: | |
| schedule: | |
| # Runs at 0700 UTC daily | |
| - cron: "0 7 * * *" | |
| workflow_dispatch: # Allow manual trigger | |
| permissions: | |
| contents: read | |
| env: | |
| SALT_FILE: tests/testcore/shard_salt.txt | |
| BRANCH: auto/optimize-test-sharding | |
| jobs: | |
| update-salts: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate GitHub token | |
| id: generate-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }} | |
| private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }} | |
| owner: temporalio | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| token: ${{ steps.generate-token.outputs.token }} | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Optimize functional test sharding | |
| run: | | |
| # NOTE: shard count must match shards in run-tests.yml | |
| go run ./cmd/tools/optimize-test-sharding \ | |
| -shards 3 \ | |
| -workflow run-tests.yml \ | |
| -artifact-pattern 'junit-xml--*shard*--functional-test' \ | |
| -file "${{ env.SALT_FILE }}" \ | |
| -threshold 0.05 | |
| env: | |
| GH_TOKEN: ${{ steps.generate-token.outputs.token }} | |
| - name: Create pull request | |
| run: | | |
| if git diff --quiet; then | |
| echo "No changes to shard salt" | |
| exit 0 | |
| fi | |
| # Delete remote branch if it exists from a previous run. | |
| # This will also close a previous, stuck PR if it exists. | |
| git push origin --delete ${{ env.BRANCH }} 2>/dev/null || true | |
| git config --local user.name 'Temporal Data' | |
| git config --local user.email 'commander-data@temporal.io' | |
| git checkout -b ${{ env.BRANCH }} | |
| git add "${{ env.SALT_FILE }}" | |
| git commit -m "Update test shard salt" | |
| git push origin ${{ env.BRANCH }} | |
| gh pr create \ | |
| --title "Update test shard salt" \ | |
| --body "Automatically generated by the optimize-test-sharding workflow." | |
| gh pr merge ${{ env.BRANCH }} --auto --squash | |
| env: | |
| GH_TOKEN: ${{ steps.generate-token.outputs.token }} |