-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
68 lines (63 loc) · 1.93 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Build, test and analyze
on:
pull_request:
branches: [ master ]
workflow_call:
jobs:
# Run linter to ensure new code respect coding rules
lint:
name: Lint code
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 20
- name: Setup metrics
run: npm ci
- name: Check contributions requirements
run: npm run test-contrib
env:
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
- name: Run linter
run: npm run linter
# Build docker image from branch and run tests
build:
name: Build and test
runs-on: ubuntu-latest
needs: [ lint ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Format code with dprint
run: |
npm install -g dprint
mkdir -v -p /home/runner/.cache/dprint/cache
npx dprint fmt --config .github/config/dprint.json
- name: Build lowlighter/metrics:${{ github.head_ref || 'master' }}
env:
GIT_REF: ${{ github.head_ref || 'master' }}
run: docker build -t lowlighter/metrics:$(echo $GIT_REF | sed 's/[^a-z]/-/g') .
- name: Run tests
env:
GIT_REF: ${{ github.head_ref || 'master' }}
run: docker run --rm --entrypoint="" lowlighter/metrics:$(echo $GIT_REF | sed 's/[^a-z]/-/g') npm run test-metrics
# Run CodeQL on branch
analyze:
name: Analyze code
runs-on: ubuntu-latest
needs: [ lint ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup CodeQL
uses: github/codeql-action/init@v2
with:
languages: javascript
config-file: ./.github/config/codeql.yml
- name: Analyze code
uses: github/codeql-action/analyze@v2