|
1 | 1 | name: Build
|
| 2 | +permissions: |
| 3 | + contents: read |
2 | 4 |
|
3 | 5 | on:
|
4 | 6 | push:
|
|
7 | 9 |
|
8 | 10 | jobs:
|
9 | 11 |
|
10 |
| - build: |
11 |
| - |
| 12 | + lint: |
12 | 13 | runs-on: ubuntu-latest
|
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + - uses: actions/setup-node@v4 |
| 17 | + with: |
| 18 | + node-version: 20 |
| 19 | + cache: 'npm' |
13 | 20 |
|
| 21 | + - name: Install dependencies |
| 22 | + run: | |
| 23 | + npm ci --no-audit |
| 24 | + npm audit |
| 25 | + |
| 26 | + - name: Run linter |
| 27 | + run: npm run lint |
| 28 | + |
| 29 | + tests: |
| 30 | + needs: [lint] |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + strategy: |
| 34 | + fail-fast: true |
| 35 | + matrix: |
| 36 | + test-type: [unit, e2e] |
| 37 | + |
14 | 38 | env:
|
15 | 39 | ATLASCODE_FX3_API_KEY: ${{ secrets.ATLASCODE_FX3_API_KEY }}
|
16 | 40 | ATLASCODE_FX3_ENVIRONMENT: ${{ vars.ATLASCODE_FX3_ENVIRONMENT }}
|
17 | 41 | ATLASCODE_FX3_TARGET_APP: ${{ vars.ATLASCODE_FX3_TARGET_APP }}
|
18 | 42 | ATLASCODE_FX3_TIMEOUT: ${{ vars.ATLASCODE_FX3_TIMEOUT }}
|
19 | 43 |
|
20 | 44 | steps:
|
21 |
| - |
22 | 45 | - uses: actions/checkout@v4
|
23 |
| - |
24 |
| - - name: Set up Node.js |
25 |
| - uses: actions/setup-node@v4 |
| 46 | + - uses: actions/setup-node@v4 |
26 | 47 | with:
|
27 | 48 | node-version: 20
|
28 | 49 | cache: 'npm'
|
29 | 50 |
|
30 | 51 | - name: Install dependencies
|
31 |
| - run: | |
32 |
| - npm ci --no-audit |
33 |
| - npm audit |
| 52 | + run: npm ci --no-audit |
34 | 53 |
|
35 | 54 | - name: Build and package the extension
|
| 55 | + if: matrix.test-type == 'e2e' |
36 | 56 | run: npm run extension:package
|
37 | 57 |
|
38 |
| - - name: Run linter |
39 |
| - run: npm run lint |
40 |
| - |
41 |
| - - name: Run unit tests |
42 |
| - run: npm run test |
43 |
| - |
44 | 58 | - name: Generate SSL certs for E2E test
|
| 59 | + if: matrix.test-type == 'e2e' |
45 | 60 | run: npm run test:e2e:sslcerts
|
46 | 61 |
|
47 | 62 | - name: Fetch E2E image
|
| 63 | + if: matrix.test-type == 'e2e' |
48 | 64 | run: |
|
49 | 65 | docker pull ghcr.io/atlassian/atlascode-e2e:latest
|
50 | 66 | docker tag ghcr.io/atlassian/atlascode-e2e:latest atlascode-e2e
|
51 | 67 |
|
| 68 | + - name: Run unit tests |
| 69 | + if: matrix.test-type == 'unit' |
| 70 | + run: npm run test |
| 71 | + |
52 | 72 | - name: Run E2E tests
|
| 73 | + if: matrix.test-type == 'e2e' |
53 | 74 | run: npm run test:e2e:docker
|
| 75 | + |
| 76 | + - name: Upload E2E artifacts |
| 77 | + if: matrix.test-type == 'e2e' && always() && hashFiles('./test-results/**') != '' |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: e2e-test-results |
| 81 | + path: ./test-results |
| 82 | + retention-days: 1 |
0 commit comments