-
Notifications
You must be signed in to change notification settings - Fork 17
160 lines (123 loc) · 4.56 KB
/
python.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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Django
on:
push:
branches: [master]
pull_request:
branches: [master]
permissions:
contents: read
pull-requests: write
jobs:
build-and-test-django:
runs-on: ubuntu-latest
steps:
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- uses: getong/elasticsearch-action@v1.3
with:
elasticsearch version: '7.7.0'
host port: 9200
container port: 9200
host node port: 9300
node port: 9300
discovery type: 'single-node'
- name: Redis Server in GitHub Actions
uses: supercharge/redis-github-action@1.8.0
with:
# Redis version to use
redis-version: '5.0.5'
- name: Setup PostgreSQL
uses: Harmon758/postgresql-action@v1.0.0
with:
# Version of PostgreSQL to use
postgresql version: '12'
postgresql db: peterbecom
postgresql user: user
postgresql password: secret
- uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'
- name: Cache node_modules
uses: actions/cache@v4
id: cached-node_modules
with:
path: |
node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('.github/workflows/python.yml') }}
- name: Install yarn packages
if: steps.cached-node_modules.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile
- name: Install uv
id: setup-uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: 'uv.lock'
- name: Celebrate uv cache hit
if: steps.setup-uv.outputs.cache-hit == 'true'
run: echo "Cache was restored"
- name: Set up Python
run: uv python install 3.12.7
- name: Install the project
run: uv sync
- name: Make sure it's synced
run: |
# If the uv.lock (dependencies and devDependencies) is
# in correct sync with pyproject.toml running `uv sync`
# should *not* make an edit to the uv.lock. I.e.
# running `git status` should
# say "nothing to commit, working tree clean".
git diff --exit-code
- name: Fix the uv.lock
# if: ${{ failure() && github.event_name != 'pull_request' && (github.actor != 'dependabot[bot]' || github.actor != 'peterbe') }}
if: ${{ failure() }}
run: |
# Update the uv.lock for them
set -e
echo "DEBUG EVENT NAME: ${{ github.event_name }}"
echo "DEBUG ACTOR: ${{ github.actor }}"
echo "--------------------------------------------------------------------"
echo ""
git diff --exit-code || uv sync
echo "--------------------------------------------------------------------"
echo ""
git status
echo ""
echo "CURRENT BRANCH NAME:"
git branch
git fetch origin
echo "TRYING TO CHECK OUT: ${{ github.head_ref || github.ref_name}}"
git checkout ${{ github.head_ref || github.ref_name}}
echo "NEW CURRENT BRANCH NAME:"
git branch
git add uv.lock
echo "--------------------------------------------------------------------"
echo ""
git config --global user.name "peterbe"
git config --global user.email "peterbe@users.noreply.github.com"
echo "COMMIT:_____________________________________________________________"
git commit -m "Update uv.lock"
echo "PUSH:_______________________________________________________________"
git push origin ${{ github.head_ref || github.ref_name}}
- name: Inspect virtual env
run: |
echo "SIZE OF .venv:"
du -sh .venv
- name: Install system dependencies
run: sudo apt-get install pngquant
- name: Download NLTK dependencies
run: uv run python scripts/nltk-downloads.py
- name: Run Lints
run: uv run ruff check .
- name: Run Tests
run: |
./scripts/ci-test.sh