-
Notifications
You must be signed in to change notification settings - Fork 8
97 lines (93 loc) · 3.54 KB
/
main.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Run tests
on: [pull_request]
jobs:
build:
name: tests-pass
runs-on: ubuntu-latest
if: github.triggering_actor != 'dependabot[bot]'
permissions:
contents: 'read'
id-token: 'write'
pull-requests: 'write'
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.7
uses: actions/setup-python@v5
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest
run: |
coverage run -m pytest tests
coverage xml -o coverage/python.xml
- name: Report python coverage
uses: orgoro/coverage@v3
with:
coverageFile: coverage/python.xml
token: ${{ secrets.GITHUB_TOKEN }}
- name: 'Authenticate to Google Cloud'
id: 'auth'
uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: 'projects/855475113448/locations/global/workloadIdentityPools/eto-github/providers/eto-github'
service_account: 'eto-artifact-registry-github@gcp-cset-projects.iam.gserviceaccount.com'
token_format: 'access_token'
- name: 'Log into Artifact Registry'
uses: 'docker/login-action@v3'
with:
registry: us-east1-docker.pkg.dev
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Test with jest
shell: bash
run: |
python3 scripts/preprocess.py
cd supply-chain
npm run artifactregistry-login
npm install
npm test -- --coverage --coverageReporters="json-summary" --coverageReporters="text" | tee ./coverage.txt
- name: Report javascript coverage
uses: MishaKav/[email protected]
with:
title: "JavaScript Coverage"
summary-title: "Summary"
coverage-title: "Modified Files"
github-token: ${{ secrets.GITHUB_TOKEN }}
report-only-changed-files: true
coverage-path: ./supply-chain/coverage.txt
coverage-summary-path: ./supply-chain/coverage/coverage-summary.json
coverage-path-prefix: supply-chain/src/
- name: Run linting
run: |
pre-commit run --all-files
- name: Build output files
run: |
cd supply-chain
npm run build
- name: Check links in built files
id: link_check
run: |
cd supply-chain
find public -name "*.js" -exec grep -Eo "(http|https):\/\/[^\{\}\"'\\ ]+" {} \; | sort -u > linklist.txt
printf '%s\n%s\n' "# LinkChecker URL list\n# <meta charset="UTF-8">" "$(cat linklist.txt)" > linklist.txt
linkchecker linklist.txt --check-extern --ignore-url="https://.*\.fastly\.net/.*" --ignore-url="https://.*\.mapbox\..*" --ignore-url="https://docs.google.com/forms/d/e/.*" -o failures > output.txt || true
cat output.txt
echo "num_links=$(wc -l < output.txt | sed 's/^ *//g')" >> $GITHUB_OUTPUT
echo "links<<EOFdelimiter" >> $GITHUB_OUTPUT
echo "$(cat output.txt)" >> $GITHUB_OUTPUT
echo "EOFdelimiter" >> $GITHUB_OUTPUT
- name: Edit PR comment about link checking
if: steps.link_check.outputs.num_links > 0
uses: thollander/actions-comment-pull-request@v2
with:
message: |
There are ${{ steps.link_check.outputs.num_links }} broken links. Check the code for these links:
${{ steps.link_check.outputs.links }}
comment_tag: link_check_msg