-
Notifications
You must be signed in to change notification settings - Fork 4
132 lines (110 loc) · 3.94 KB
/
afids-validator_ci.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: AFIDs Validator CI Workflow
on:
pull_request_target:
types: [opened, reopened, synchronize, ready_for_review, closed]
jobs:
test:
name: Setup environment & test
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Setup python environment
uses: khanlab/actions/.github/actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
install-library: "true"
- name: Start PostgreSQL services
shell: bash
run: |
sudo systemctl start postgresql.service
pg_isready
- name: Setup PostgreSQL db
shell: bash
env:
psql_db_owner: testuser # PostgreSQL User
psql_db_pw: testpass # PostgreSQL Pass
psql_db_name: testdb # PostgreSQL DB
run: |
sudo -u postgres psql --command="CREATE USER $psql_db_owner PASSWORD '$psql_db_pw'"
sudo -u postgres createdb --owner=$psql_db_owner $psql_db_name
PGPASSWORD=$psql_db_pw psql --username=$psql_db_owner --host=localhost --list $psql_db_name
- name: Test AFIDs validator
shell: bash
env:
FLASK_ENV: testing # Sets flask environment
DATABASE_URL: postgresql://testuser:testpass@localhost/testdb
run: |
poetry run python -m unittest
linting:
name: Lint code
needs: [test]
if: github.event.pull_request.merged == false
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Setup python environment
uses: khanlab/actions/.github/actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: ruff
run: poetry run ruff afidsvalidator test
- name: isort
run: poetry run isort afidsvalidator test -c
- name: black
run: poetry run black afidsvalidator test --check
build-frontend:
needs: [linting]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache node installation
uses: actions/cache@v3
with:
path: ~/.local
key: ${{ runner.os }}-node-${{ github.event.pull_request.id }}
- name: Install node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install react dependencies
run: |
npm --prefix afidsvalidator/static/lib/afidsvalidator-react install
- name: Build react frontend
run: |
npm run --prefix afidsvalidator/static/lib/afidsvalidator-react build
- name: Check changes
run: |
gh_status=$(git status --porcelain)
if [ -z "$gh_status" ]; then
echo 'modified="false"' >> $GITHUB_ENV
else
echo 'modified="true"' >> $GITHUB_ENV
fi
- name: Commit changes
if: env.modified == 'true'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git diff-index --quiet HEAD || git commit -m "[BOT] Build react frontend" -a
- name: Push to repo
if: env.modified == 'true'
uses: CasperWA/push-protected@v2
with:
branch: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.BP_PAT_TOKEN }}
unprotect_reviews: true
assign-reviewer:
needs: [build-frontend]
if: github.event.pull_request.assignee == null
uses: khanlab/actions/.github/workflows/[email protected]
update_changelog:
if: github.event.pull_request.merged == true
uses: khanlab/actions/.github/workflows/[email protected]
secrets:
BP_PAT: ${{ secrets.BP_PAT_TOKEN }}