Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure python 3.12 is supported #37

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 52 additions & 63 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ concurrency:
permissions:
contents: read

env:
FORCE_COLOR: 1
PIP_DISABLE_PIP_VERSION_CHECK: 1

jobs:
build:
name: Build dist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"
- name: Install Poetry
run: pipx install poetry
- name: Build release
Expand All @@ -39,81 +43,73 @@ jobs:
name: dist
path: dist/

test-wheel:
name: Test wheel
test-dists:
name: Test Built ${{ matrix.dist.name }} (${{ matrix.python-version }})
runs-on: ubuntu-latest
needs: [build]
needs: build
strategy:
fail-fast: false
matrix:
python-version:
- "3.10"
- "3.12"
dist:
- name: "wheel"
extension: whl
- name: "sdist"
extension: tar.gz
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "${{ matrix.python-version }}"
cache: pip
- name: Download release dists
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Install wheel
- name: Install ${{ matrix.dist.name }}
run: |
export path_to_file=$(find dist -type f -name "problem_bank_helpers-*.whl")
echo "::notice::Installing wheel: $path_to_file"
export path_to_file=$(find dist -type f -name "problem_bank_helpers-*.${{ matrix.dist.extension }}")
echo "::notice::Installing ${{ matrix.dist.name }}: $path_to_file"
python -m pip install --user $path_to_file
python -m pip list
- name: Install test dependencies
run: python -m pip install --user pytest
- name: Run tests against installed wheel
run: rm -rf src/ && pytest tests/

test-sdist:
name: Test sdist
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- name: Download release dists
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Install sdist
run: |
export path_to_file=$(find dist -type f -name "problem_bank_helpers-*.tar.gz")
echo "::notice::Installing sdist: $path_to_file"
python -m pip install --user $path_to_file
python -m pip list
- name: Install test dependencies
run: python -m pip install --user pytest
- name: Run tests against installed sdist
run: rm -rf src/ && pytest tests/

test-banks:
name: Test Problem Banks Build
needs: [build]
name: Test ${{ matrix.bank.name }} Problem Bank Builds (${{ matrix.python-version }})
continue-on-error: ${{ matrix.python-version == '3.12'}}
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false # We want to know all issues, even if one fails
matrix:
repo: # If more problem banks are ever created, add them here
- instructor_physics_bank
- instructor_datascience_bank
- instructor_stats_bank
python-version:
- "3.10"
- "3.12"
bank:
- name: Physics
repo: open-resources/instructor_physics_bank
- name: Data Science
repo: open-resources/instructor_datascience_bank
- name: Statistics
repo: open-resources/instructor_stats_bank
steps:
- name: Checkout ${{ matrix.repo }}
- name: Checkout ${{ matrix.bank.name }} Problem Bank
uses: actions/checkout@v4
with:
repository: open-resources/${{ matrix.repo }}
repository: ${{ matrix.bank.repo }}
token: ${{ secrets.API_TOKEN_GITHUB }}
- name: Set up Python 3.10
ref: main
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "${{ matrix.python-version }}"
cache: pip
- name: Download release dists
uses: actions/download-artifact@v4
Expand All @@ -126,21 +122,16 @@ jobs:
python -m pip install --upgrade problem_bank_scripts
- name: Install built wheel
run: |
python -m pip uninstall -y problem_bank_helpers
export path_to_file=$(find dist -type f -name "problem_bank_helpers-*.whl")
echo "::notice::Installing wheel: $path_to_file"
python -m pip install --user $path_to_file
python -m pip list
python -m pip install --user $(find dist -type f -name "problem_bank_helpers-*.whl")
- name: Test problem bank generates properly
run: python scripts/process.py 'source' --instructor=True --public=True --prairielearn=True
run: process 'source' --instructor=True --public=True --prairielearn=True

publish:
name: Publish new release to PyPI
if: github.event_name == 'release' # only publish to PyPI on releases
needs: # Ensure build and tests have passed before publishing
- build
- test-wheel
- test-sdist
# Ensure tests have passed and problem banks can be built
needs:
- test-dists
- test-banks
runs-on: ubuntu-latest
# Specifying a GitHub environment so manual approval by an approved user to create a release is required
Expand All @@ -165,12 +156,13 @@ jobs:

github-release:
name: upload dists to GitHub release
needs: [publish]
needs: publish
runs-on: ubuntu-latest

permissions:
id-token: write
attestations: write
contents: write
runs-on: ubuntu-latest

steps:
- name: Download release dists
Expand All @@ -185,10 +177,7 @@ jobs:
- name: Upload Dists to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
run: gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}'

push-to-question-banks:
uses: ./.github/workflows/update-dependents.yml
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Create new Release

on:
push:
tags:
- 'v*.*.*'

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write

if: ${{ github.actor_id == '2507459' || github.actor_id == '68259537' }}

steps:
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.API_TOKEN_GITHUB }}
run: gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}' --generate-notes
95 changes: 52 additions & 43 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,59 @@
name: Tests

on:
push:
branches: [main]
paths:
- "tests/**"
- "src/**"
- "pyproject.toml"
- "poetry.lock"
- ".github/workflows/tests.yml"
pull_request:
branches: [main]
paths:
- "tests/**"
- "src/**"
- "pyproject.toml"
- "poetry.lock"
- ".github/workflows/tests.yml"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
merge_group:
push:
branches: [main]
paths:
- "tests/**"
- "src/**"
- "pyproject.toml"
- "poetry.lock"
- ".github/workflows/tests.yml"
pull_request:
branches: [main]
paths:
- "tests/**"
- "src/**"
- "pyproject.toml"
- "poetry.lock"
- ".github/workflows/tests.yml"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read
contents: read

env:
FORCE_COLOR: 1
PIP_DISABLE_PIP_VERSION_CHECK: 1

jobs:
tests:
runs-on: ubuntu-latest
#strategy:
concurrency:
group: tests-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- name: Install Poetry --with dev
run: |
curl -sSL https://install.python-poetry.org | python -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: poetry
- name: Install dependencies
run: |
poetry install
- name: Run tests
run: |
poetry run pytest tests
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version:
- "3.10"
- "3.12"
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: |
pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
cache: poetry
- name: Install dependencies
run: |
poetry install --with dev
- name: Run tests
run: |
poetry run pytest tests
6 changes: 3 additions & 3 deletions .github/workflows/update-dependents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ jobs:
# as shown here: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#example-expanding-configurations
steps:
- name: Checkout ${{ matrix.repo }}
uses: actions/checkout@v3
uses: actions/checkout@v4
with: # checks out default branch
repository: ${{ matrix.repo }}
token: ${{ secrets.PAT_GITHUB_PRAIRIELEARN }}
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'
- name: Update pbh version in serverFilesCourse
run: |
rm -rf serverFilesCourse/problem_bank_helpers serverFilesCourse/problem_bank_helpers-*.dist-info
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@ dmypy.json
**.Rhistory

*.DS_Store

poetry.toml

8 changes: 1 addition & 7 deletions bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@ echo $ret
FROM=$(echo $ret | awk '{ print $4; }')
TO=$(echo $ret | awk '{ print $6; }')

# change any references to the old version in the project
echo "Bumping version from $FROM to $TO in src/problem_bank_helpers/__init__.py"
sed -i "s/__version__ = \"$FROM\"/__version__ = \"$TO\"/g" src/problem_bank_helpers/__init__.py
echo "Bumping version from $FROM to $TO in tests/test_problem_bank_helpers.py"
sed -i "s/__version__ == \"$FROM\"/__version__ == \"$TO\"/g" tests/test_problem_bank_helpers.py

# commit the changes
git add src/problem_bank_helpers/__init__.py tests/test_problem_bank_helpers.py pyproject.toml
git add pyproject.toml
git commit -m "Increment version from $FROM to $TO"

# create a tag
Expand Down
Loading
Loading