|
| 1 | +name: Test and Report |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + pull_request: |
| 7 | + branches: ["main"] |
| 8 | + |
| 9 | +# Set default permissions to read-only |
| 10 | +permissions: read-all |
| 11 | + |
| 12 | +jobs: |
| 13 | + prepare: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + # Only needs read permissions |
| 16 | + permissions: |
| 17 | + contents: read # Required to check out code |
| 18 | + steps: |
| 19 | + - name: Harden the runner (Audit all outbound calls) |
| 20 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 21 | + with: |
| 22 | + egress-policy: audit |
| 23 | + |
| 24 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 25 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 26 | + with: |
| 27 | + node-version: "24" |
| 28 | + cache: "npm" |
| 29 | + |
| 30 | + - name: Setup display and dependencies |
| 31 | + run: | |
| 32 | + sudo apt-get update |
| 33 | + sudo apt-get install -y xvfb libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2t64 libxtst6 xauth |
| 34 | + sudo mkdir -p /var/run/dbus |
| 35 | + sudo dbus-daemon --system --fork |
| 36 | +
|
| 37 | + - name: Cache dependencies |
| 38 | + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 39 | + with: |
| 40 | + path: ~/.npm |
| 41 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 42 | + restore-keys: | |
| 43 | + ${{ runner.os }}-node- |
| 44 | +
|
| 45 | + - name: Install dependencies |
| 46 | + run: npm install |
| 47 | + |
| 48 | + - name: Cache Cypress binary |
| 49 | + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 50 | + with: |
| 51 | + path: ~/.cache/Cypress |
| 52 | + key: cypress-${{ runner.os }}-${{ hashFiles('**/package.json') }} |
| 53 | + |
| 54 | + - name: Verify Cypress |
| 55 | + run: npx cypress verify |
| 56 | + |
| 57 | + build-validation: |
| 58 | + needs: prepare |
| 59 | + runs-on: ubuntu-latest |
| 60 | + # Needs write permissions to upload artifacts |
| 61 | + permissions: |
| 62 | + contents: write # Required to check out code |
| 63 | + actions: read # Required to use GitHub actions |
| 64 | + id-token: write # Required for attestation |
| 65 | + pull-requests: write # Required to upload artifacts (implicit permission) |
| 66 | + steps: |
| 67 | + - name: Harden the runner (Audit all outbound calls) |
| 68 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 69 | + with: |
| 70 | + egress-policy: audit |
| 71 | + |
| 72 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 73 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 74 | + with: |
| 75 | + node-version: "24" |
| 76 | + cache: "npm" |
| 77 | + |
| 78 | + - name: Cache dependencies |
| 79 | + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 80 | + with: |
| 81 | + path: ~/.npm |
| 82 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 83 | + restore-keys: | |
| 84 | + ${{ runner.os }}-node- |
| 85 | +
|
| 86 | + - name: Install dependencies |
| 87 | + run: npm ci |
| 88 | + |
| 89 | + - name: Build application |
| 90 | + run: npm run build |
| 91 | + |
| 92 | + - name: Upload build artifacts |
| 93 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 94 | + with: |
| 95 | + name: build-output |
| 96 | + path: build |
| 97 | + if-no-files-found: error |
| 98 | + |
| 99 | + unit-tests: |
| 100 | + needs: [prepare, build-validation] |
| 101 | + runs-on: ubuntu-latest |
| 102 | + # Needs write permissions to upload artifacts |
| 103 | + permissions: |
| 104 | + contents: write # Required to check out code |
| 105 | + actions: read # Required to use GitHub actions |
| 106 | + checks: write # Required to upload artifacts (implicit permission) |
| 107 | + steps: |
| 108 | + - name: Harden the runner (Audit all outbound calls) |
| 109 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 110 | + with: |
| 111 | + egress-policy: audit |
| 112 | + |
| 113 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 114 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 115 | + with: |
| 116 | + node-version: "24" |
| 117 | + cache: "npm" |
| 118 | + |
| 119 | + - name: Install dependencies |
| 120 | + run: npm install |
| 121 | + |
| 122 | + - name: Run unit tests with coverage |
| 123 | + run: xvfb-run --auto-servernum npm run test:ci |
| 124 | + env: |
| 125 | + JEST_JUNIT_OUTPUT_DIR: "coverage" |
| 126 | + JEST_JUNIT_OUTPUT_NAME: "junit.xml" |
| 127 | + |
| 128 | + - name: Upload coverage report |
| 129 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 130 | + with: |
| 131 | + name: coverage-report |
| 132 | + path: coverage |
| 133 | + if-no-files-found: error |
| 134 | + |
| 135 | + e2e-tests: |
| 136 | + needs: [prepare, build-validation] |
| 137 | + runs-on: ubuntu-latest |
| 138 | + # Needs write permissions to upload artifacts |
| 139 | + permissions: |
| 140 | + contents: write # Required to check out code |
| 141 | + actions: read # Required to use GitHub actions |
| 142 | + checks: write # Required to upload artifacts (implicit permission) |
| 143 | + pull-requests: write |
| 144 | + steps: |
| 145 | + - name: Harden the runner (Audit all outbound calls) |
| 146 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 147 | + with: |
| 148 | + egress-policy: audit |
| 149 | + |
| 150 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 151 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 152 | + with: |
| 153 | + node-version: "24" |
| 154 | + cache: "npm" |
| 155 | + |
| 156 | + - name: Install dependencies |
| 157 | + run: npm install |
| 158 | + |
| 159 | + - name: Start app and run Cypress tests |
| 160 | + run: | |
| 161 | + xvfb-run --auto-servernum --server-args="-screen 0 1280x720x24" npm run test:e2e |
| 162 | + env: |
| 163 | + CYPRESS_VIDEO: true |
| 164 | + |
| 165 | + - name: Upload Cypress results |
| 166 | + if: always() |
| 167 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 168 | + with: |
| 169 | + name: cypress-results |
| 170 | + path: | |
| 171 | + cypress/videos |
| 172 | + cypress/screenshots |
| 173 | + cypress/results |
| 174 | +
|
| 175 | + report: |
| 176 | + needs: [unit-tests, e2e-tests] |
| 177 | + runs-on: ubuntu-latest |
| 178 | + if: always() |
| 179 | + # Needs write permissions to upload artifacts |
| 180 | + permissions: |
| 181 | + contents: write # Required to check out code |
| 182 | + actions: read # Required to use GitHub actions |
| 183 | + checks: write # Required to upload artifacts (implicit permission) |
| 184 | + steps: |
| 185 | + - name: Harden the runner (Audit all outbound calls) |
| 186 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 187 | + with: |
| 188 | + egress-policy: audit |
| 189 | + |
| 190 | + - name: Download all artifacts |
| 191 | + uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1 |
| 192 | + with: |
| 193 | + path: artifacts |
| 194 | + |
| 195 | + - name: Upload combined reports |
| 196 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 197 | + with: |
| 198 | + name: test-reports |
| 199 | + path: | |
| 200 | + coverage |
| 201 | + artifacts/cypress-results |
0 commit comments