-
Notifications
You must be signed in to change notification settings - Fork 1
178 lines (155 loc) · 5.6 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
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
name: CI
on: [push]
permissions:
contents: write
pull-requests: write
jobs:
'build-frontend':
name: Build Frontend
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install Node.JS
uses: actions/setup-node@v4
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
# Upload the entire workspace
- name: Upload entire workspace
uses: actions/upload-artifact@v4
with:
name: workspace
path: .
# retention-days: 1
'test-frontend':
name: Test Frontend
needs: ['build-frontend']
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
# Download the entire workspace
- name: Download workspace
uses: actions/download-artifact@v4
with:
name: workspace
path: .
- name: Install Node.JS
uses: actions/setup-node@v4
- name: Install dependencies
run: npm ci
- name: Test
run: npm run test
'test-backend':
runs-on: ubuntu-latest
name: Python ${{ matrix.python-version }} sample with Postgres ${{ matrix.postgres-version }}
needs: ['build-frontend']
strategy:
matrix:
python-version: [
'3.9',
'3.10',
'3.11',
'3.12',
'3.13',
'pypy-3.9',
'pypy-3.10',
#'pypy-3.11',
]
postgres-version: ['13', '14', '15', '16', '17']
continue-on-error: true
services:
database:
image: postgres:${{ matrix.postgres-version }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
DJANGO_DATABASE_HOST: localhost
DJANGO_DATABASE_USER: postgres
DJANGO_DATABASE_PASSWORD: postgres
DJANGO_DATABASE_NAME: postgres
steps:
# Download the entire workspace
- name: Download workspace
uses: actions/download-artifact@v4
with:
name: workspace
path: .
- uses: nanasess/setup-chromedriver@v2
- run: |
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install python dependencies
run: |
poetry install
poetry run pip install -e .
- name: Run tests
run: |
poetry run pytest -v -x -rs
merge:
runs-on: ubuntu-latest
needs: ['test-backend', 'test-frontend']
if: github.actor == 'dependabot[bot]' # Detect that the PR author is dependabot
steps:
- uses: actions/checkout@v4
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL" # Use Github CLI to merge automatically the PR
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
release:
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: ['test-frontend', 'test-backend']
environment:
name: pypi
url: https://pypi.org/project/django-hstore-widget
permissions:
contents: write
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
# Download the entire workspace
- name: Download workspace
uses: actions/download-artifact@v4
with:
name: workspace
path: .
- name: Build the dependency
run: poetry build --output py-dist
- name: Upload package to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: py-dist/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: py-dist/