-
-
Notifications
You must be signed in to change notification settings - Fork 2
149 lines (119 loc) · 4.13 KB
/
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
name: Run tests & display coverage
runs-on: ubuntu-latest
steps:
- run: echo "event name is:" ${{ github.event_name }}
- run: echo "event type is:" ${{ github.event.action }}
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Install developer dependencies
run: make install-dependencies
- name: Lint with flake8
run: make flake8
- name: Run tests and produce .coverage file
run: make test
- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
- name: Check coding style
run: make black-check
- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v3
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
# If you use a different name, update COMMENT_ARTIFACT_NAME accordingly
name: python-coverage-comment-action
# If you use a different name, update COMMENT_FILENAME accordingly
path: python-coverage-comment-action.txt
flake8-badge:
if: github.event_name == 'push'
name: Update flake8 badge
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Install developer dependencies
run: make install-dependencies
- name: Lint with flake8
run: make flake8
- name: Determine badge message and color
run: make flake8-badge | tail -1 | (IFS="@" read MESSAGE COLOR;
echo "FLAKE8_BADGE_MESSAGE=$MESSAGE" >> $GITHUB_ENV;
echo "FLAKE8_BADGE_COLOR=$COLOR" >> $GITHUB_ENV)
- name: Set up JSON file for badge
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 1cfaee423c85504cd204cf4649e2cf29
filename: flake8-badge.json
label: flake8
message: ${{ env.FLAKE8_BADGE_MESSAGE }}
color: ${{ env.FLAKE8_BADGE_COLOR }}
eslint-badge:
if: github.event_name == 'push'
name: Update eslint badge
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: Setup JS environment
run: cd js && npm install
- name: Determine badge message and color
run: make eslint-badge | tail -1 | (IFS="@" read MESSAGE COLOR;
echo "ESLINT_BADGE_MESSAGE=$MESSAGE" >> $GITHUB_ENV;
echo "ESLINT_BADGE_COLOR=$COLOR" >> $GITHUB_ENV)
- name: Set up JSON file for badge
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 1cfaee423c85504cd204cf4649e2cf29
filename: eslint-badge.json
label: eslint
message: ${{ env.ESLINT_BADGE_MESSAGE }}
color: ${{ env.ESLINT_BADGE_COLOR }}
# based on https://stackoverflow.com/a/64373702
build-docker:
name: Build docker image & run tests
runs-on: ubuntu-latest
env:
COMPOSE_FILE: docker/docker-compose.yml
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build docker images
run: docker-compose build web
- name: Run tests
run: docker-compose run web python -m pytest
push-docker:
if: github.event_name == 'push'
name: Push docker image
runs-on: ubuntu-latest
env:
COMPOSE_FILE: docker/docker-compose.yml
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build docker images
run: docker-compose build web
- name: Login to ghcr
run: echo ${{ github.token }} | docker login ghcr.io -u hgrf --password-stdin
- name: Push to ghcr
run: docker push ghcr.io/hgrf/racine:latest