From 7b15fb6ea20351bef096f3fa610a24e5321b8bc8 Mon Sep 17 00:00:00 2001 From: seitzdom <39090287+dominikandreasseitz@users.noreply.github.com> Date: Tue, 10 Oct 2023 16:56:14 +0200 Subject: [PATCH] [Infra] Add Publish Step (#28) Co-authored-by: Niklas Heim --- .../{build_docs.yml => build_deploy_docs.yml} | 7 ++-- .github/workflows/dependabot.yml | 6 +++ .github/workflows/lint.yml | 7 +++- .github/workflows/publish.yml | 41 +++++++++++++++++++ .github/workflows/test_all.yml | 10 +++-- ...amples_notebooks.yml => test_examples.yml} | 21 ++++------ .github/workflows/test_fast.yml | 10 +++-- pyproject.toml | 2 +- 8 files changed, 80 insertions(+), 24 deletions(-) rename .github/workflows/{build_docs.yml => build_deploy_docs.yml} (91%) create mode 100644 .github/workflows/dependabot.yml create mode 100644 .github/workflows/publish.yml rename .github/workflows/{test_examples_notebooks.yml => test_examples.yml} (61%) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_deploy_docs.yml similarity index 91% rename from .github/workflows/build_docs.yml rename to .github/workflows/build_deploy_docs.yml index bb9e693d..f34c4299 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_deploy_docs.yml @@ -1,4 +1,4 @@ -name: Build documentation +name: Build & deploy documentation on: push: @@ -16,10 +16,11 @@ concurrency: jobs: test_qadence_ubuntu: name: Test Qadence docs (ubuntu) - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout Qadence + uses: actions/checkout@v4 - name: Install JetBrains Mono font run: | diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml new file mode 100644 index 00000000..b38df29f --- /dev/null +++ b/.github/workflows/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9d15a2ec..3aa78451 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: linting and type check +name: Lint and type check on: push: @@ -10,19 +10,22 @@ on: jobs: lint: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: Checkout Qadence uses: actions/checkout@v4 + - name: Set up Python 3.x uses: actions/setup-python@v4 with: python-version: '3.x' + - name: Install pre-commit run: | pip install pre-commit pre-commit install + - name: Check files run: | pre-commit run --all-files diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..8d6fafac --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,41 @@ +name: Upload release to PyPI + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Check out Qadence + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + pip install hatch + + - name: Build and publish package + run: | + hatch build + hatch publish -u ${{ secrets.HATCH_PYPI_USER }} -a ${{ secrets.HATCH_PYPI_AUTH }} + + - name: Confirm deployment + timeout-minutes: 5 + run: | + VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//') + echo "VERSION=$VERSION" >> $GITHUB_ENV + until pip download qadence==$version + do + echo "Failed to download from PyPI, will wait for upload and retry." + sleep 1 + done diff --git a/.github/workflows/test_all.yml b/.github/workflows/test_all.yml index 3bcb0453..2f726970 100644 --- a/.github/workflows/test_all.yml +++ b/.github/workflows/test_all.yml @@ -7,25 +7,29 @@ on: workflow_dispatch: {} concurrency: - group: ${{ github.head_ref || github.run_id }} + group: all-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: test_qadence_ubuntu: name: Test Qadence (ubuntu) - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: python-version: ["3.9", "3.10"] steps: - - uses: actions/checkout@v4 + - name: Checkout Qadence + uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + - name: Install Hatch run: | pip install hatch + - name: Run tests run: | hatch -v run test diff --git a/.github/workflows/test_examples_notebooks.yml b/.github/workflows/test_examples.yml similarity index 61% rename from .github/workflows/test_examples_notebooks.yml rename to .github/workflows/test_examples.yml index 51c74eff..e75a442e 100644 --- a/.github/workflows/test_examples_notebooks.yml +++ b/.github/workflows/test_examples.yml @@ -1,4 +1,4 @@ -name: Run Qadence example and notebook tests. +name: Run Qadence example tests on: push: @@ -7,34 +7,31 @@ on: pull_request: branches: - main - paths: - - examples - - notebooks - schedule: - # 03:00 every Saturday morning - - cron: '0 3 * * 6' workflow_dispatch: {} concurrency: - group: ${{ github.head_ref || github.run_id }} + group: examples-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: test_qadence_ubuntu: name: Test Qadence (ubuntu) - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + + - name: Install graphviz + run: sudo apt-get install -y graphviz + - name: Select Python 3.10 uses: actions/setup-python@v4 with: python-version: '3.10' + - name: Install Hatch run: | pip install hatch + - name: Run example tests run: | hatch -v run test-examples - - name: Run notebooks tests - run: | - hatch -v run test-notebooks diff --git a/.github/workflows/test_fast.yml b/.github/workflows/test_fast.yml index f0cbdb0d..2b46a3ba 100644 --- a/.github/workflows/test_fast.yml +++ b/.github/workflows/test_fast.yml @@ -1,4 +1,4 @@ -name: fast tests +name: Fast tests on: push: @@ -10,29 +10,33 @@ on: workflow_dispatch: {} concurrency: - group: ${{ github.head_ref || github.run_id }} + group: fast-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: test_qadence_ubuntu: name: Test Qadence (ubuntu) - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: python-version: ["3.9", "3.10"] steps: - name: Checkout Qadence uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + - name: Install Hatch run: | pip install hatch + - name: Run fast tests run: | hatch -v run test -m "not slow" + - name: Upload coverage data uses: actions/upload-artifact@v3 with: diff --git a/pyproject.toml b/pyproject.toml index 0c67dc34..c0f0d260 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ authors = [ ] requires-python = ">=3.9,<3.11" license = {text = "Apache 2.0"} -version = "0.9.1" +version = "0.9.2" classifiers=[ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python",