-
Notifications
You must be signed in to change notification settings - Fork 2
202 lines (171 loc) · 5.76 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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Continuous Integration
# Enable Buildkit and let compose use it to speed up image building
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
POETRY_VERSION: 1.8.3 # Make sure this matches the Dockerfile
on:
pull_request:
branches:
- master
push:
branches:
- master
tags:
- "v*"
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- id: poetry-cache
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
- if: steps.poetry-cache.outputs.cache-hit != 'true'
name: Install Poetry and Dependencies
shell: bash
run: |
pip install --upgrade pip
pip install poetry==$POETRY_VERSION
python -m venv .venv
source .venv/bin/activate
poetry install --with dev,test
- name: ruff
shell: bash
run: |
source .venv/bin/activate
ruff check . --output-format=github
- name: Black
shell: bash
run: |
source .venv/bin/activate
black . --check
test:
runs-on: ubuntu-22.04
needs: [lint]
container:
image: python:3.12-slim-bookworm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FLASK_CONFIGURATION: development
FLASK_ENV: development
TENLISTS_SECRET_KEY_DEV: fake
MAIL_SERVER_DEV: smtp.mailtrap.io
MAIL_PORT_DEV: 2525
TENLISTS_EMAIL_USER_DEV: ''
TENLISTS_EMAIL_PWD_DEV: ''
MAIL_USE_TLS: True
MAIL_USE_SSL: False
TENLISTS_MP3_CLOUD_STORAGE_BASE_URL: https://example.com/path/to/folder
TENLISTS_API_BASE: http://localhost:8000/ten-lists/api/v1.0/mp3s
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: System Dependencies
shell: bash
run: |
apt-get update --yes --quiet
apt-get install --yes --quiet --no-install-recommends build-essential curl ffmpeg git
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
apt-get install -y nodejs
npm install -g grunt-cli
npm ci --cache .npm --prefer-offline
grunt all
- name: Install Python dependencies & testing tools
shell: bash
run: |
pip install --upgrade pip
python -m pip install poetry==1.8.3
poetry install --with dev,test
curl https://deepsource.io/cli | sh
- name: Create .env file to simulate a development setup
shell: bash
run: |
mkdir -p env/
touch env/.dev.env
echo "TENLISTS_SECRET_KEY_DEV='fake'" >> env/.dev.env
echo "MAIL_SERVER_DEV=smtp.mailtrap.io" >> env/.dev.env
echo "MAIL_PORT_DEV=2525" >> env/.dev.env
echo "TENLISTS_EMAIL_USER_DEV=" >> env/.dev.env
echo "TENLISTS_EMAIL_PWD_DEV=" >> env/.dev.env
echo "MAIL_USE_TLS=True" >> env/.dev.env
echo "MAIL_USE_SSL=False" >> env/.dev.env
echo "TENLISTS_MP3_CLOUD_STORAGE_BASE_URL=https://example.com/path/to/folder" >> env/.dev.env
echo "TENLISTS_API_BASE=http://localhost:8000/ten-lists/api/v1.0/mp3s" >> env/.dev.env
- name: Run tests
run: |
poetry run pytest
- name: DeepSource
uses: deepsourcelabs/test-coverage-action@master
with:
key: python
coverage-file: coverage.xml
dsn: ${{ secrets.DEEPSOURCE_DSN }}
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ github.token }}
- name: Codacy Coverage Reporter
uses: codacy/codacy-coverage-reporter-action@v1.3.0
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# or
# api-token: ${{ secrets.CODACY_API_TOKEN }}
coverage-reports: coverage.xml
# Creates a GitHub Release when the lint & test jobs succeeds, and only on pushes to tags.
release:
needs: [lint, test]
permissions:
contents: write
if: needs.test.result == 'success' && startsWith( github.ref, 'refs/tags/v' )
runs-on: ubuntu-22.04
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- id: poetry-cache
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
- if: steps.poetry-cache.outputs.cache-hit != 'true'
name: Install Poetry and Dependencies
shell: bash
run: |
pip install --upgrade pip
pip install poetry==$POETRY_VERSION
python -m venv .venv
source .venv/bin/activate
poetry install --with dev,test
- name: Get the version
id: get_version
run: |
echo "${{ github.ref }}"
echo "VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\///')" >> $GITHUB_ENV
- name: Generate Release Title
id: get_release_title
shell: bash
run: |
export TODAY="($(TZ=Africa/Lusaka date --iso))"
echo "RELEASE_NAME=$VERSION $TODAY" >> $GITHUB_ENV
- name: Extract Release Notes
# This creates a file LATEST_RELEASE_NOTES.md in the parent directory (../)
shell: bash
run: |
source .venv/bin/activate
invoke get-release-notes
- name: GitHub Release
uses: softprops/action-gh-release@v1
with:
name: ${{ env.RELEASE_NAME }}
body_path: ../LATEST_RELEASE_NOTES.md