[ui, ci] retain artifacts from test runs including test timing #4976
This file contains 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: test-ui | |
on: | |
pull_request: | |
paths: | |
- "ui/**" | |
push: | |
branches: | |
- main | |
- release/** | |
- test-ui | |
paths: | |
- "ui/**" | |
jobs: | |
pre-test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: ui | |
outputs: | |
nonce: ${{ steps.nonce.outputs.nonce }} | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: ./.github/actions/setup-js | |
- name: lint:js | |
run: yarn run lint:js | |
- name: lint:hbs | |
run: yarn run lint:hbs | |
- id: nonce | |
name: nonce | |
run: echo "nonce=${{ github.run_id }}-$(date +%s)" >> "$GITHUB_OUTPUT" | |
tests: | |
needs: | |
- pre-test | |
runs-on: ${{ endsWith(github.repository, '-enterprise') && fromJSON('["self-hosted", "ondemand", "linux", "type=m7a.2xlarge;m6a.2xlarge"]') || 'ubuntu-latest' }} | |
timeout-minutes: 30 | |
continue-on-error: true | |
defaults: | |
run: | |
working-directory: ui | |
strategy: | |
matrix: | |
partition: [1, 2, 3, 4] | |
split: [4] | |
# Note: If we ever change the number of partitions, we'll need to update the | |
# finalize.combine step to match | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: ./.github/actions/setup-js | |
- uses: browser-actions/setup-chrome@facf10a55b9caf92e0cc749b4f82bf8220989148 # v1.7.2 | |
- name: Retrieve Vault-hosted Secrets | |
if: endsWith(github.repository, '-enterprise') | |
id: vault | |
uses: hashicorp/vault-action@d1720f055e0635fd932a1d2a48f87a666a57906c # v3.0.0 | |
with: | |
url: ${{ vars.CI_VAULT_URL }} | |
method: ${{ vars.CI_VAULT_METHOD }} | |
path: ${{ vars.CI_VAULT_PATH }} | |
jwtGithubAudience: ${{ vars.CI_VAULT_AUD }} | |
secrets: |- | |
kv/data/teams/nomad/ui PERCY_TOKEN ; | |
# - name: Create results directory | |
# run: mkdir -p ui/test-results | |
# - name: ember exam | |
# env: | |
# PERCY_TOKEN: ${{ env.PERCY_TOKEN || secrets.PERCY_TOKEN }} | |
# PERCY_PARALLEL_NONCE: ${{ needs.pre-test.outputs.nonce }} | |
# run: | | |
# yarn exam:parallel --split=${{ matrix.split }} --partition=${{ matrix.partition }} --json-report=test-results-${{ matrix.partition }}.json | |
- name: Create fake file | |
run: | | |
mkdir -p test-results | |
touch test-results/faux-${{ matrix.partition }}.json | |
ls -la test-results/ # Debug: List directory contents | |
pwd # Debug: Show current directory | |
echo "File exists: $(test -f test-results/faux-${{ matrix.partition }}.json && echo "yes" || echo "no")" | |
# run: | | |
# mkdir -p test-results | |
# touch test-results/faux-${{ matrix.partition }}.json | |
- name: Upload partition test results | |
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: test-results-${{ matrix.partition }} | |
path: ui/test-results/faux-${{ matrix.partition }}.json | |
retention-days: 90 | |
finalize: | |
needs: | |
- pre-test | |
- tests | |
runs-on: ${{ endsWith(github.repository, '-enterprise') && fromJSON('["self-hosted", "ondemand", "linux", "type=m7a.2xlarge;m6a.2xlarge"]') || 'ubuntu-latest' }} | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: ui | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: ./.github/actions/setup-js | |
- name: Retrieve Vault-hosted Secrets | |
if: endsWith(github.repository, '-enterprise') | |
id: vault | |
uses: hashicorp/vault-action@d1720f055e0635fd932a1d2a48f87a666a57906c # v3.0.0 | |
with: | |
url: ${{ vars.CI_VAULT_URL }} | |
method: ${{ vars.CI_VAULT_METHOD }} | |
path: ${{ vars.CI_VAULT_PATH }} | |
jwtGithubAudience: ${{ vars.CI_VAULT_AUD }} | |
secrets: |- | |
kv/data/teams/nomad/ui PERCY_TOKEN ; | |
- name: Download all test results | |
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
pattern: test-results-* | |
path: test-results | |
- name: Debug directory structure | |
run: | | |
echo "Current directory:" | |
pwd | |
echo "Root directory contents:" | |
ls -la .. | |
echo "Test results directory contents:" | |
ls -la ../test-results || echo "test-results directory not found" | |
- name: Combine test results for comparison | |
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
# Note: iterator is hardcoded to 4 to match matrix partitions | |
run: | | |
node -e " | |
const fs = require('fs'); | |
const results = []; | |
// Log where I am | |
console.log('Current directory:', process.cwd()); | |
for (let i = 1; i <= 4; i++) { | |
const data = JSON.parse(fs.readFileSync('../test-results/faux-' + i)); | |
results.push(...data.testResults); | |
} | |
fs.writeFileSync('combined-test-results.json', JSON.stringify({ | |
timestamp: new Date().toISOString(), | |
sha: process.env.GITHUB_SHA, | |
testResults: results | |
}, null, 2)); | |
" | |
- name: Upload combined results for comparison | |
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: test-results-${{ github.sha }} | |
path: combined-test-results.json | |
retention-days: 90 | |
- name: finalize | |
env: | |
PERCY_TOKEN: ${{ env.PERCY_TOKEN || secrets.PERCY_TOKEN }} | |
PERCY_PARALLEL_NONCE: ${{ needs.pre-test.outputs.nonce }} | |
run: yarn percy build:finalize | |
permissions: | |
contents: read | |
id-token: write |