Skip to content

Commit 213582d

Browse files
authored
Merge pull request #37 from open-resources/update-python
Make sure `python 3.12` is supported
2 parents 228952c + c9b25d4 commit 213582d

File tree

11 files changed

+539
-571
lines changed

11 files changed

+539
-571
lines changed

.github/workflows/publish.yml

+52-63
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ concurrency:
1919
permissions:
2020
contents: read
2121

22+
env:
23+
FORCE_COLOR: 1
24+
PIP_DISABLE_PIP_VERSION_CHECK: 1
25+
2226
jobs:
2327
build:
2428
name: Build dist
2529
runs-on: ubuntu-latest
2630
steps:
2731
- uses: actions/checkout@v4
28-
- name: Set up Python 3.10
32+
- name: Set up Python 3.12
2933
uses: actions/setup-python@v5
3034
with:
31-
python-version: "3.10"
35+
python-version: "3.12"
3236
- name: Install Poetry
3337
run: pipx install poetry
3438
- name: Build release
@@ -39,81 +43,73 @@ jobs:
3943
name: dist
4044
path: dist/
4145

42-
test-wheel:
43-
name: Test wheel
46+
test-dists:
47+
name: Test Built ${{ matrix.dist.name }} (${{ matrix.python-version }})
4448
runs-on: ubuntu-latest
45-
needs: [build]
49+
needs: build
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
python-version:
54+
- "3.10"
55+
- "3.12"
56+
dist:
57+
- name: "wheel"
58+
extension: whl
59+
- name: "sdist"
60+
extension: tar.gz
4661
steps:
4762
- uses: actions/checkout@v4
48-
- name: Set up Python 3.10
63+
- name: Set up Python ${{ matrix.python-version }}
4964
uses: actions/setup-python@v5
5065
with:
51-
python-version: "3.10"
66+
python-version: "${{ matrix.python-version }}"
5267
cache: pip
5368
- name: Download release dists
5469
uses: actions/download-artifact@v4
5570
with:
5671
name: dist
5772
path: dist/
58-
- name: Install wheel
73+
- name: Install ${{ matrix.dist.name }}
5974
run: |
60-
export path_to_file=$(find dist -type f -name "problem_bank_helpers-*.whl")
61-
echo "::notice::Installing wheel: $path_to_file"
75+
export path_to_file=$(find dist -type f -name "problem_bank_helpers-*.${{ matrix.dist.extension }}")
76+
echo "::notice::Installing ${{ matrix.dist.name }}: $path_to_file"
6277
python -m pip install --user $path_to_file
6378
python -m pip list
6479
- name: Install test dependencies
6580
run: python -m pip install --user pytest
6681
- name: Run tests against installed wheel
6782
run: rm -rf src/ && pytest tests/
6883

69-
test-sdist:
70-
name: Test sdist
71-
runs-on: ubuntu-latest
72-
needs: [build]
73-
steps:
74-
- uses: actions/checkout@v4
75-
- name: Set up Python 3.10
76-
uses: actions/setup-python@v5
77-
with:
78-
python-version: "3.10"
79-
cache: pip
80-
- name: Download release dists
81-
uses: actions/download-artifact@v4
82-
with:
83-
name: dist
84-
path: dist/
85-
- name: Install sdist
86-
run: |
87-
export path_to_file=$(find dist -type f -name "problem_bank_helpers-*.tar.gz")
88-
echo "::notice::Installing sdist: $path_to_file"
89-
python -m pip install --user $path_to_file
90-
python -m pip list
91-
- name: Install test dependencies
92-
run: python -m pip install --user pytest
93-
- name: Run tests against installed sdist
94-
run: rm -rf src/ && pytest tests/
95-
9684
test-banks:
97-
name: Test Problem Banks Build
98-
needs: [build]
85+
name: Test ${{ matrix.bank.name }} Problem Bank Builds (${{ matrix.python-version }})
86+
continue-on-error: ${{ matrix.python-version == '3.12'}}
87+
needs: build
9988
runs-on: ubuntu-latest
10089
strategy:
10190
fail-fast: false # We want to know all issues, even if one fails
10291
matrix:
103-
repo: # If more problem banks are ever created, add them here
104-
- instructor_physics_bank
105-
- instructor_datascience_bank
106-
- instructor_stats_bank
92+
python-version:
93+
- "3.10"
94+
- "3.12"
95+
bank:
96+
- name: Physics
97+
repo: open-resources/instructor_physics_bank
98+
- name: Data Science
99+
repo: open-resources/instructor_datascience_bank
100+
- name: Statistics
101+
repo: open-resources/instructor_stats_bank
107102
steps:
108-
- name: Checkout ${{ matrix.repo }}
103+
- name: Checkout ${{ matrix.bank.name }} Problem Bank
109104
uses: actions/checkout@v4
110105
with:
111-
repository: open-resources/${{ matrix.repo }}
106+
repository: ${{ matrix.bank.repo }}
112107
token: ${{ secrets.API_TOKEN_GITHUB }}
113-
- name: Set up Python 3.10
108+
ref: main
109+
- name: Set up Python ${{ matrix.python-version }}
114110
uses: actions/setup-python@v5
115111
with:
116-
python-version: "3.10"
112+
python-version: "${{ matrix.python-version }}"
117113
cache: pip
118114
- name: Download release dists
119115
uses: actions/download-artifact@v4
@@ -126,21 +122,16 @@ jobs:
126122
python -m pip install --upgrade problem_bank_scripts
127123
- name: Install built wheel
128124
run: |
129-
python -m pip uninstall -y problem_bank_helpers
130-
export path_to_file=$(find dist -type f -name "problem_bank_helpers-*.whl")
131-
echo "::notice::Installing wheel: $path_to_file"
132-
python -m pip install --user $path_to_file
133-
python -m pip list
125+
python -m pip install --user $(find dist -type f -name "problem_bank_helpers-*.whl")
134126
- name: Test problem bank generates properly
135-
run: python scripts/process.py 'source' --instructor=True --public=True --prairielearn=True
127+
run: process 'source' --instructor=True --public=True --prairielearn=True
136128

137129
publish:
138130
name: Publish new release to PyPI
139131
if: github.event_name == 'release' # only publish to PyPI on releases
140-
needs: # Ensure build and tests have passed before publishing
141-
- build
142-
- test-wheel
143-
- test-sdist
132+
# Ensure tests have passed and problem banks can be built
133+
needs:
134+
- test-dists
144135
- test-banks
145136
runs-on: ubuntu-latest
146137
# Specifying a GitHub environment so manual approval by an approved user to create a release is required
@@ -165,12 +156,13 @@ jobs:
165156

166157
github-release:
167158
name: upload dists to GitHub release
168-
needs: [publish]
159+
needs: publish
160+
runs-on: ubuntu-latest
161+
169162
permissions:
170163
id-token: write
171164
attestations: write
172165
contents: write
173-
runs-on: ubuntu-latest
174166

175167
steps:
176168
- name: Download release dists
@@ -185,10 +177,7 @@ jobs:
185177
- name: Upload Dists to GitHub Release
186178
env:
187179
GITHUB_TOKEN: ${{ github.token }}
188-
run: |
189-
gh release upload
190-
'${{ github.ref_name }}' dist/**
191-
--repo '${{ github.repository }}'
180+
run: gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}'
192181

193182
push-to-question-banks:
194183
uses: ./.github/workflows/update-dependents.yml

.github/workflows/release.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Create new Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
14+
if: ${{ github.actor_id == '2507459' || github.actor_id == '68259537' }}
15+
16+
steps:
17+
- name: Create GitHub Release
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.API_TOKEN_GITHUB }}
20+
run: gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}' --generate-notes

.github/workflows/tests.yml

+52-43
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,59 @@
11
name: Tests
22

33
on:
4-
push:
5-
branches: [main]
6-
paths:
7-
- "tests/**"
8-
- "src/**"
9-
- "pyproject.toml"
10-
- "poetry.lock"
11-
- ".github/workflows/tests.yml"
12-
pull_request:
13-
branches: [main]
14-
paths:
15-
- "tests/**"
16-
- "src/**"
17-
- "pyproject.toml"
18-
- "poetry.lock"
19-
- ".github/workflows/tests.yml"
20-
# Allows you to run this workflow manually from the Actions tab
21-
workflow_dispatch:
22-
merge_group:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "tests/**"
8+
- "src/**"
9+
- "pyproject.toml"
10+
- "poetry.lock"
11+
- ".github/workflows/tests.yml"
12+
pull_request:
13+
branches: [main]
14+
paths:
15+
- "tests/**"
16+
- "src/**"
17+
- "pyproject.toml"
18+
- "poetry.lock"
19+
- ".github/workflows/tests.yml"
20+
# Allows you to run this workflow manually from the Actions tab
21+
workflow_dispatch:
22+
merge_group:
23+
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
26+
cancel-in-progress: true
2327

2428
permissions:
25-
contents: read
29+
contents: read
30+
31+
env:
32+
FORCE_COLOR: 1
33+
PIP_DISABLE_PIP_VERSION_CHECK: 1
2634

2735
jobs:
28-
tests:
29-
runs-on: ubuntu-latest
30-
#strategy:
31-
concurrency:
32-
group: tests-${{ github.ref }}
33-
cancel-in-progress: true
34-
steps:
35-
- uses: actions/checkout@v3
36-
- name: Install Poetry --with dev
37-
run: |
38-
curl -sSL https://install.python-poetry.org | python -
39-
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
40-
- name: Set up Python 3.10
41-
uses: actions/setup-python@v4
42-
with:
43-
python-version: "3.10"
44-
cache: poetry
45-
- name: Install dependencies
46-
run: |
47-
poetry install
48-
- name: Run tests
49-
run: |
50-
poetry run pytest tests
36+
tests:
37+
runs-on: ubuntu-latest
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
python-version:
42+
- "3.10"
43+
- "3.12"
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: Install Poetry
47+
run: |
48+
pipx install poetry
49+
- name: Set up Python ${{ matrix.python-version }}
50+
uses: actions/setup-python@v5
51+
with:
52+
python-version: "${{ matrix.python-version }}"
53+
cache: poetry
54+
- name: Install dependencies
55+
run: |
56+
poetry install --with dev
57+
- name: Run tests
58+
run: |
59+
poetry run pytest tests

.github/workflows/update-dependents.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ jobs:
2525
# as shown here: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#example-expanding-configurations
2626
steps:
2727
- name: Checkout ${{ matrix.repo }}
28-
uses: actions/checkout@v3
28+
uses: actions/checkout@v4
2929
with: # checks out default branch
3030
repository: ${{ matrix.repo }}
3131
token: ${{ secrets.PAT_GITHUB_PRAIRIELEARN }}
3232
- name: Setup Python
33-
uses: actions/setup-python@v4
33+
uses: actions/setup-python@v5
3434
with:
35-
python-version: '3.10'
35+
python-version: '3.12'
3636
- name: Update pbh version in serverFilesCourse
3737
run: |
3838
rm -rf serverFilesCourse/problem_bank_helpers serverFilesCourse/problem_bank_helpers-*.dist-info

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,6 @@ dmypy.json
139139
**.Rhistory
140140

141141
*.DS_Store
142+
143+
poetry.toml
144+

bump.sh

+1-7
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,8 @@ echo $ret
1414
FROM=$(echo $ret | awk '{ print $4; }')
1515
TO=$(echo $ret | awk '{ print $6; }')
1616

17-
# change any references to the old version in the project
18-
echo "Bumping version from $FROM to $TO in src/problem_bank_helpers/__init__.py"
19-
sed -i "s/__version__ = \"$FROM\"/__version__ = \"$TO\"/g" src/problem_bank_helpers/__init__.py
20-
echo "Bumping version from $FROM to $TO in tests/test_problem_bank_helpers.py"
21-
sed -i "s/__version__ == \"$FROM\"/__version__ == \"$TO\"/g" tests/test_problem_bank_helpers.py
22-
2317
# commit the changes
24-
git add src/problem_bank_helpers/__init__.py tests/test_problem_bank_helpers.py pyproject.toml
18+
git add pyproject.toml
2519
git commit -m "Increment version from $FROM to $TO"
2620

2721
# create a tag

0 commit comments

Comments
 (0)