Repository navigation
173 lines (157 loc) · 4.93 KB
/
Copy pathpre-commit.yml
File metadata and controls
173 lines (157 loc) · 4.93 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
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
name: pull-request
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- edited
- reopened
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
name: pre-commit checks
uses: bitbrew-dev/reusable-workflows/.github/workflows/prek.yml@main
permissions:
contents: read
packages: read
secrets: inherit
with:
prek_skip: fmt,check,clippy,test,go-sdk-tests
check-change-files:
name: check-changed-files
outputs:
rust: ${{ steps.check-changes.outputs.rust_any_modified }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
- name: get rust modules that have changed
id: check-changes
uses: tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1
with:
files_yaml: |
rust:
- crates/**/src/**
- crates/**/tests/**
- crates/**/Cargo.toml
- crates/fmp-py-gen/registry/**
- Cargo.toml
- Cargo.lock
- rust-toolchain.toml
- .github/workflows/*.yml
rust-ci:
name: rust ci
runs-on: ubuntu-latest
needs: check-change-files
if: needs.check-change-files.outputs.rust == 'true'
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
steps:
- name: checkout repository
uses: actions/checkout@v5
- name: free disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache
docker image prune -af
docker builder prune -af
- name: install the toolchain pinned in rust-toolchain.toml
run: |
rustup toolchain install
rustup show active-toolchain
- name: restore cargo caches
uses: Swatinem/rust-cache@v2
- name: check formatting
run: cargo fmt --all -- --check
- name: run clippy
run: cargo clippy --workspace --all-targets -- -D warnings
- name: compile tests
run: cargo test --workspace --no-run
- name: run tests
run: cargo test --workspace
python-bindings:
name: python bindings (${{ matrix.python-version }})
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.13"]
env:
CARGO_TERM_COLOR: always
steps:
- name: checkout repository
uses: actions/checkout@v5
- name: install the toolchain pinned in rust-toolchain.toml
run: |
rustup toolchain install
rustup show active-toolchain
- name: restore cargo caches
uses: Swatinem/rust-cache@v2
- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: create a venv with maturin, pytest and mypy
run: |
python -m venv "$GITHUB_WORKSPACE/.venv"
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> "$GITHUB_ENV"
echo "$GITHUB_WORKSPACE/.venv/bin" >> "$GITHUB_PATH"
# mypy enables tests/test_stubs.py (stubtest + typecheck contract), which skips without it.
"$GITHUB_WORKSPACE/.venv/bin/pip" install --no-cache-dir "maturin>=1.9,<2" pytest "mypy>=2.3,<3"
- name: build and install the fmp extension module
working-directory: crates/fmp-py
run: maturin develop
- name: run the python tests
run: pytest crates/fmp-py/tests -v
pr-labeler:
name: pr labeler
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.head.repo.fork == false }}
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: checkout repository
uses: actions/checkout@v5
- name: pr labeler
uses: actions/labeler@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/labeler.yml
workflow-success:
name: workflow-success
needs:
- pre-commit
- rust-ci
- python-bindings
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: report required job results
env:
PRE_COMMIT_RESULT: ${{ needs.pre-commit.result }}
RUST_CI_RESULT: ${{ needs.rust-ci.result }}
PYTHON_BINDINGS_RESULT: ${{ needs.python-bindings.result }}
run: |
echo "pre-commit: $PRE_COMMIT_RESULT"
echo "rust ci: $RUST_CI_RESULT"
echo "python bindings: $PYTHON_BINDINGS_RESULT"
for result in \
"$PRE_COMMIT_RESULT" \
"$RUST_CI_RESULT" \
"$PYTHON_BINDINGS_RESULT"
do
test "$result" = "success" || test "$result" = "skipped"
done