-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (51 loc) · 1.55 KB
/
validate-csv.yml
File metadata and controls
57 lines (51 loc) · 1.55 KB
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
name: "Validate CSV"
on:
push:
paths:
- "daily-log.csv"
pull_request:
paths:
- "daily-log.csv"
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install test deps
run: |
python -m pip install --upgrade pip
pip install pytest
- name: Run unit tests
run: |
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
pytest -q
- name: Run validator (capture output)
id: runvalidator
run: |
set -e
python3 scripts/validate_csv.py > validator-output.txt 2>&1 || true
rc=$?
echo "rc=$rc"
echo "::set-output name=rc::$rc"
- name: Comment on PR with validator output
if: ${{ github.event_name == 'pull_request' && steps.runvalidator.outputs.rc != '0' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const out = fs.readFileSync('validator-output.txt', 'utf8');
const body = `CSV validator found issues:\n\n```
+ out + '\n```';
const pr = context.payload.pull_request.number;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr,
body: body
});