-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic packaging and CI test updates (#386)
* Reorganizing the requirements locations * WIP: Trying out composite Github actions * Incorporating composite Github action in CI suite * Make CI run on all PRs * Bug: Requirements files were switched * Moving jsonschema to requirements * Installing only the necessary requirements in CI * Adding pytest to type-checking required packages * Complementing the CI test description * WIP: Test version check * WIP: Check new version validity * WIP: Test version validity [fail 1] * WIP: Test version check [fail 2] * Bring version back * Trigger new workflow run * WIP: Test stable version validity [fail 3] * WIP: Test stable version validity [pass] * Finish version checker tests * Adding full test workflow * Make full tests run on push only * Centralizing the different packages * Add packaging script * WIP: Test publish workflow * Test: Trigger 'publish' workflow * WIP: 2nd 'publish' workflow test * WIP: 3rd 'publish' workflow test * Finish the 'publish' workflow * Documenting the Release procedure * Review comments + Details on merge commit messages * Adding review suggestions
- Loading branch information
Showing
21 changed files
with
351 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exit if something fails | ||
set -e | ||
|
||
# Find and change to the repository directory | ||
repo_dir=$(git rev-parse --show-toplevel) | ||
cd "${repo_dir}" | ||
|
||
# Removing existing files in /dist | ||
rm -rf dist | ||
|
||
packages=$(cat packages.txt) | ||
# Build the pulser packages | ||
for pkg in $packages | ||
do | ||
echo "Packaging $pkg" | ||
python $pkg/setup.py -q bdist_wheel -d "../dist" | ||
rm -r $pkg/build | ||
done | ||
|
||
# Build the pulser metapackage | ||
python setup.py -q bdist_wheel -d "dist" | ||
rm -r build | ||
|
||
echo "Built wheels:" | ||
ls dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Upload Release Package to PyPI | ||
|
||
on: | ||
release: | ||
types: [released] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out Pulser | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.ref }} | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine | ||
- name: Build packages | ||
shell: bash | ||
run: ./.github/scripts/package.sh | ||
- name: Publish to TestPyPI | ||
env: | ||
TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.TESTPYPI_PASSWORD }} | ||
run: twine upload --repository testpypi dist/* | ||
- name: Install from TestPyPI | ||
timeout-minutes: 5 | ||
shell: bash | ||
run: | | ||
version="$(head -1 VERSION.txt)" | ||
until pip install -i https://test.pypi.org/simple/ pulser==$version --extra-index-url https://pypi.org/simple | ||
do | ||
echo "Failed to install from TestPyPI, will wait for upload and retry." | ||
sleep 30 | ||
done | ||
- name: Test the installation | ||
# Installs pytest from dev_requirements.txt (in case it has a version specifier) | ||
run: | | ||
grep -e pytest dev_requirements.txt | sed 's/ //g' | xargs pip install | ||
pytest | ||
- name: Publish to PyPI | ||
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
run: twine upload dist/* | ||
|
||
check-release: | ||
needs: deploy | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: ['3.7', '3.8', '3.9', '3.10'] | ||
steps: | ||
- name: Check out Pulser | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.ref }} | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Pulser from PyPI | ||
shell: bash | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pulser | ||
- name: Test the installation | ||
shell: bash | ||
run: | | ||
version="$(head -1 VERSION.txt)" | ||
python -c "import pulser; assert pulser.__version__ == '$version'" | ||
grep -e pytest dev_requirements.txt | sed 's/ //g' | xargs pip install | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Pulser setup | ||
description: "Sets up Python and installs Pulser." | ||
inputs: | ||
python-version: | ||
description: Python version | ||
required: false | ||
default: '3.9' | ||
extra-packages: | ||
description: Extra packages to install (give to grep) | ||
required: false | ||
default: '' | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
cache: 'pip' | ||
- name: Install Pulser | ||
shell: bash | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -e ./pulser-core -e ./pulser-simulation | ||
- name: Install extra packages from the dev requirements | ||
if: "${{ inputs.extra-packages != '' }}" | ||
shell: bash | ||
run: | | ||
grep -e ${{ inputs.extra-packages }} dev_requirements.txt \ | ||
| sed 's/ //g' \ | ||
| xargs pip install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
|
||
jobs: | ||
full-tests: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: ['3.7', '3.8', '3.9', '3.10'] | ||
steps: | ||
- name: Check out Pulser | ||
uses: actions/checkout@v3 | ||
- name: Pulser + pytest setup | ||
uses: ./.github/workflows/pulser-setup | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
extra-packages: pytest | ||
- name: Run the unit tests & generate coverage report | ||
run: pytest --cov --cov-fail-under=100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: version | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'VERSION.txt' | ||
|
||
jobs: | ||
validate-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out base branch | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.base.ref }} | ||
- name: Get old version | ||
run: | | ||
old_version="$(head -1 VERSION.txt)" | ||
echo "Old version: $old_version" | ||
echo "old_version=$old_version" >> $GITHUB_ENV | ||
- name: Check out head branch | ||
uses: actions/checkout@v3 | ||
- name: Get new version | ||
run: | | ||
new_version="$(head -1 VERSION.txt)" | ||
echo "New version: $new_version" | ||
echo "new_version=$new_version" >> $GITHUB_ENV | ||
- name: Compare versions | ||
run: dpkg --compare-versions "${{ env.old_version }}" lt "${{ env.new_version }}" | ||
- name: Check stable version validity | ||
if: github.event.pull_request.base.ref == 'master' | ||
run: | | ||
pattern=^\(0\|[1-9]\d*\)\.\(0\|[1-9]\d*\)\.\(0\|[1-9]\d*\)$ | ||
if [[ ${{ env.new_version }} =~ $pattern ]]; then | ||
echo "New version is valid."; exit 0 | ||
else | ||
echo "New version is invalid."; exit 1 | ||
fi | ||
- name: Check development version validity | ||
if: github.event.pull_request.base.ref != 'master' | ||
run: | | ||
pattern=^\(0\|[1-9]\d*\)\.\(0\|[1-9]\d*\)dev\(0\|[1-9]\d*\)$ | ||
if [[ ${{ env.new_version }} =~ $pattern ]]; then | ||
echo "New version is valid."; exit 0 | ||
else | ||
echo "New version is invalid."; exit 1 | ||
fi | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
include README.md | ||
include requirements.txt | ||
include LICENSE | ||
include VERSION.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.6.0.dev | ||
0.7dev0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# tests | ||
black | ||
black[jupyter] | ||
flake8 | ||
flake8-docstrings | ||
isort | ||
mypy == 0.921 | ||
pytest | ||
pytest-cov | ||
|
||
# CI | ||
pre-commit | ||
|
||
# tutorials | ||
notebook | ||
python-igraph | ||
scikit-optimize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pulser-core | ||
pulser-simulation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
jsonschema == 4.4.0 | ||
matplotlib | ||
numpy >= 1.20 | ||
scipy | ||
backports.cached-property; python_version == '3.7' | ||
typing-extensions; python_version == '3.7' |
Oops, something went wrong.