-
Notifications
You must be signed in to change notification settings - Fork 73
66 lines (54 loc) · 2.22 KB
/
migration-sql.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
name: Alembic consistency check
on:
pull_request:
branches: [master]
jobs:
check-alembic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Get list of created migrations
id: get-changed-files
uses: umani/[email protected]
with:
repo-token: ${{ github.token }}
result-encoding: json
pattern: '^newdle/migrations/versions/.+\.py$'
- name: Check if any migrations changed
id: migrations-changed
run: |
echo changed=${{ steps.get-changed-files.outputs.files_created != '[]' || steps.get-changed-files.outputs.files_updated != '[]' || steps.get-changed-files.outputs.files_deleted != '[]' }} >> $GITHUB_OUTPUT
- name: Setup venv and config file
if: steps.migrations-changed.outputs.changed == 'true'
run: |
make config
PYTHON=python3.12 make env
pip install -q -e '.[dev]'
- name: Activate virtualenv for later steps
if: steps.migrations-changed.outputs.changed == 'true'
run: |
echo "VIRTUAL_ENV=$(pwd)/.venv" >> $GITHUB_ENV
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
- name: Check history consistency
if: steps.migrations-changed.outputs.changed == 'true'
run: python ./ci/check_history_consistency.py
- name: Store PR data
run: |
mkdir /tmp/migration-sql-data
echo ${{ github.event.number }} > /tmp/migration-sql-data/pull-request-id
- name: Print changed migrations
if: steps.migrations-changed.outputs.changed == 'true'
run: |
first_migration=$(echo ${{ steps.get-changed-files.outputs.files_created }} | jq -r '.[0] // empty')
latest_migration=$(echo ${{ steps.get-changed-files.outputs.files_created }} | jq -r '.[-1] // empty')
./ci/print_revision_sql.sh $first_migration $latest_migration > /tmp/migration-sql-data/upgrade.sql
- name: Create artifact
uses: actions/upload-artifact@v4
with:
name: migration-sql-data
path: /tmp/migration-sql-data
retention-days: 1