@@ -6,131 +6,21 @@ concurrency:
6
6
group : ${{ github.workflow }}-${{ github.ref }}
7
7
cancel-in-progress : true
8
8
9
- defaults :
10
- run :
11
- shell : bash -el {0}
12
-
13
9
jobs :
14
10
linux-unittests :
15
11
name : Check project generation
16
12
timeout-minutes : 30
17
13
runs-on : ubuntu-latest
18
14
steps :
19
- - name : Checkout branch
15
+ - name : Checkout
20
16
uses : actions/checkout@v4
21
- - name : Set up Conda env
22
- uses : mamba-org/setup-micromamba@8767fb704bd78032e9392f0386bf46950bdd1194
23
- with :
24
- environment-file : environment.yml
25
- cache-environment : true
26
- create-args : >-
27
- python=3.11
28
- pytest-md
29
- pytest-emoji
30
- - name : Cache pre-commit envs
31
- uses : actions/cache@v4
32
17
with :
33
- path : |
34
- ~/.cache/pre-commit
35
- key : project-generation-pre-commit-${{ hashFiles('template/.pre-commit-config.yaml') }}
18
+ fetch-depth : 0 # copier doesn't like shallow clones
19
+ - name : Set up pixi
20
+ uses : prefix-dev/setup-pixi@ca3b9ac762955fad216e3d8e0bbf22087071c89c
36
21
- name : Run unittests
37
22
uses : quantco/pytest-action@v2
38
23
with :
39
24
report-title : Check project generation
40
25
click-to-expand : false
41
-
42
- pre-commit-checks :
43
- name : Pre-commit checks - Python 3.11
44
- timeout-minutes : 30
45
- runs-on : ubuntu-latest
46
- steps :
47
- - name : Checkout branch
48
- uses : actions/checkout@v4
49
- with :
50
- fetch-depth : 0 # Fetching the entire branch history is necessary for the 'pre-commit-insert-license' hook to recognize the actual git lifespan of a file.
51
- - name : Run pre-commit-conda
52
- uses : quantco/pre-commit-conda@v1
53
- with :
54
- python-version : " 3.11"
55
-
56
- test-generated-package-ci :
57
- name : Test CI of generated package (rattler-build = ${{ matrix.use-rattler-build }}) (mypy = ${{ matrix.use-mypy }})
58
- timeout-minutes : 30
59
- runs-on : ubuntu-latest
60
- concurrency : test-generated-package-ci-${{ github.sha }}-${{ matrix.use-rattler-build }}-${{ matrix.use-mypy }}
61
- strategy :
62
- matrix :
63
- include :
64
- - use-rattler-build : false
65
- use-mypy : true
66
- - use-rattler-build : true
67
- use-mypy : true
68
- - use-rattler-build : true
69
- use-mypy : false
70
-
71
- steps :
72
- - name : Checkout branch
73
- uses : actions/checkout@v4
74
- with :
75
- ssh-key : ${{ secrets.SSH_PRIVATE_KEY }}
76
- ref : ${{ github.head_ref }}
77
- - name : Set up Conda env
78
- uses : mamba-org/setup-micromamba@8767fb704bd78032e9392f0386bf46950bdd1194
79
- with :
80
- environment-file : environment.yml
81
- cache-environment : true
82
- - name : Test generated package CI
83
- run : |
84
- # Name of the generated package.
85
- PKG=quantcore.test-package
86
- # Authentication for pushing to $REPO.
87
- AUTH='authorization: Bearer ${{ secrets.GITHUB_TOKEN }}'
88
- eval $(ssh-agent)
89
- ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
90
- # Set up local Git so that copier can run "git commit".
91
- git config --global user.email "[email protected] "
92
- git config --global user.name "Forrest Quant"
93
- # Generate package with default settings + Windows CI.
94
- copier copy \
95
- --data project_name="Package" \
96
- --data project_short_description="Example Package" \
97
- --data use_rattler_build="${{ matrix.use-rattler-build }}" \
98
- --data use_mypy="${{ matrix.use-mypy }}" \
99
- --data github_user="ForrestQuant" \
100
- --data project_slug="$PKG" \
101
- --defaults \
102
- --trust \
103
- . out
104
- cd out
105
- # Push the generated package's HEAD commit to a `ci/*` branch
106
- cid=$(git rev-parse HEAD)
107
- git push -f "${GITHUB_SERVER_URL/https:\/\//git@}:$GITHUB_REPOSITORY" $cid:refs/heads/ci/$GITHUB_SHA-${{ matrix.use-rattler-build }}-${{ matrix.use-mypy }}
108
- # Use the GitHub API to wait for the generated package's CI to complete (success or failure).
109
- # We look for a GitHub Actions run for the HEAD commit ID.
110
- WORKFLOW_URL="$GITHUB_API_URL/repos/${GITHUB_REPOSITORY}/actions/runs?branch=ci/${GITHUB_SHA}-${{ matrix.use-rattler-build }}-${{ matrix.use-mypy }}&head_sha=${cid}"
111
- echo "Waiting for inner CI to start"
112
- while (( $(curl -Ls --header "$AUTH" "$WORKFLOW_URL" | jq -r ".workflow_runs | length") < 1 )); do
113
- sleep 10
114
- done
115
- echo "Waiting for inner CI to complete"
116
- while curl -Ls --header "$AUTH" "$WORKFLOW_URL" | jq -r ".workflow_runs | .[] | .status" | grep --invert-match completed > /dev/null; do
117
- sleep 10
118
- done
119
- # Fail unless CI was successful.
120
- if curl -Ls --header "$AUTH" "$WORKFLOW_URL" | jq -r ".workflow_runs | .[] | .conclusion" | grep --invert-match success > /dev/null; then
121
- echo "CI pipeline failed"
122
- exit 1
123
- fi
124
- - name : Clean up CI branch
125
- if : always()
126
- run : |
127
- AUTH='authorization: Bearer ${{ secrets.GITHUB_TOKEN }}'
128
- eval $(ssh-agent)
129
- ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
130
-
131
- git push -d "${GITHUB_SERVER_URL/https:\/\//git@}:$GITHUB_REPOSITORY" refs/heads/ci/$GITHUB_SHA-${{ matrix.use-rattler-build }}-${{ matrix.use-mypy }}
132
-
133
- for line in $(curl -Ls --header "$AUTH" "$GITHUB_API_URL/repos/${GITHUB_REPOSITORY}/actions/runs?branch=ci/${GITHUB_SHA}-${{ matrix.use-rattler-build }}-${{ matrix.use-mypy }}&head_sha=${cid}" | jq -r ".workflow_runs | .[] | select(.status != \"completed\") | .id")
134
- do
135
- curl -Ls --header "$AUTH" --request POST "$GITHUB_API_URL/repos/${GITHUB_REPOSITORY}/actions/runs/$line/cancel" > /dev/null
136
- done
26
+ custom-pytest : pixi run pytest
0 commit comments