Repository navigation
119 lines (100 loc) · 3.3 KB
/
Copy pathupdate_lock.yml
File metadata and controls
119 lines (100 loc) · 3.3 KB
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
name: Update lock file
on:
schedule:
- cron: '0 6 1 * *'
workflow_dispatch:
permissions: {}
jobs:
# Installs and runs the freshly updated dependencies, so it gets a read-only
# token and no stored git credentials.
update-lock:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
ref: develop
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Update lock file
run: poetry update --lock --no-interaction
# Quick check on one Python version before opening a PR. The full matrix
# runs on the PR branch via the dispatch job below.
- name: Install dependencies
run: poetry install --no-root --no-interaction
- name: Lint
run: poetry run ruff check .
- name: Type check
run: poetry run mypy
- name: Run tests
run: poetry run pytest tests
- name: Upload lock file
uses: actions/upload-artifact@v4
with:
name: poetry-lock
path: poetry.lock
retention-days: 1
# Runs no project code: it only commits the checked lock file.
open-pr:
needs: update-lock
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
operation: ${{ steps.cpr.outputs.pull-request-operation }}
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
ref: develop
persist-credentials: false
# The artifact comes from the job that ran the updated dependencies, so
# take only a regular poetry.lock file from it.
- name: Download lock file
uses: actions/download-artifact@v4
with:
name: poetry-lock
path: ${{ runner.temp }}/lock
- name: Copy lock file
env:
LOCK_DIR: ${{ runner.temp }}/lock
run: |
files=$(find "$LOCK_DIR" -mindepth 1)
if [ "$files" != "$LOCK_DIR/poetry.lock" ] || [ -L "$LOCK_DIR/poetry.lock" ] || [ ! -f "$LOCK_DIR/poetry.lock" ]; then
echo "::error::Unexpected artifact content: $files"
exit 1
fi
cp "$LOCK_DIR/poetry.lock" poetry.lock
- name: Open pull request
id: cpr
uses: peter-evans/create-pull-request@v7
with:
base: develop
branch: chore/update-lock
commit-message: "chore: update lock file"
title: "chore: update lock file"
body: "Monthly `poetry update`. Review the lock file diff and wait for CI."
add-paths: poetry.lock
delete-branch: true
# Pushes made with GITHUB_TOKEN don't trigger CI, so start it by hand.
# Its checks are reported on the PR's head commit.
run-ci:
needs: open-pr
if: needs.open-pr.outputs.operation == 'created' || needs.open-pr.outputs.operation == 'updated'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Run CI on the pull request
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: gh workflow run ci.yml --ref chore/update-lock