From d95d4862e3a7cae932ea10de661510f61ebf8827 Mon Sep 17 00:00:00 2001 From: Rory Conlin Date: Tue, 24 Oct 2023 01:29:44 -0400 Subject: [PATCH] Add github workflows --- .github/workflows/black.yml | 31 +++++++++++++++++ .github/workflows/jax_tests.yml | 38 +++++++++++++++++++++ .github/workflows/linting.yml | 23 +++++++++++++ .github/workflows/release.yml | 26 ++++++++++++++ .github/workflows/unittest.yml | 60 +++++++++++++++++++++++++++++++++ 5 files changed, 178 insertions(+) create mode 100644 .github/workflows/black.yml create mode 100644 .github/workflows/jax_tests.yml create mode 100644 .github/workflows/linting.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/unittest.yml diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 0000000..7aa5f93 --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,31 @@ +name: Black formatting + +on: [pull_request, workflow_dispatch] + +jobs: + black_format: + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + - name: Check files using the black formatter + run: | + black --version + black --check quadax/ tests/ || black_return_code=$? + echo "BLACK_RETURN_CODE=$black_return_code" >> $GITHUB_ENV + black quadax/ tests/ + - name: Annotate diff changes using reviewdog + uses: reviewdog/action-suggester@v1 + with: + tool_name: blackfmt + - name: Fail if not formatted + run: | + exit ${{ env.BLACK_RETURN_CODE }} diff --git a/.github/workflows/jax_tests.yml b/.github/workflows/jax_tests.yml new file mode 100644 index 0000000..24a8903 --- /dev/null +++ b/.github/workflows/jax_tests.yml @@ -0,0 +1,38 @@ +name: Dependency test JAX + +on: + pull_request: + types: [labeled] + workflow_dispatch: + +jobs: + jax_tests: + if: ${{ github.event.label.name == 'test_jax' && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + jax-version: [0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6, 0.3.7, 0.3.8, 0.3.9, 0.3.10, 0.3.11, 0.3.12, 0.3.13, 0.3.14, 0.3.15, 0.3.16, 0.3.17, 0.3.19, 0.3.20, 0.3.21, 0.3.22, 0.3.23, 0.3.24, 0.3.25, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.4.6, 0.4.7, 0.4.8, 0.4.9, 0.4.10, 0.4.11, 0.4.12, 0.4.13, 0.4.14] + group: [1, 2] + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: 3.9 + cache: pip + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + - name: Remove jax + run: | + pip uninstall jax jaxlib -y + - name: install jax + run: | + pip install "jax[cpu]==${{ matrix.jax-version }}" + - name: Test with pytest + run: | + pwd + lscpu + python -m pytest --durations=0 --mpl --maxfail=1 --splits 3 --group ${{ matrix.group }} --splitting-algorithm least_duration diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..a8ae7a7 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,23 @@ +name: Linting + +on: [pull_request, workflow_dispatch] + +jobs: + flake8_linting: + runs-on: ubuntu-latest + name: Linting + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + - name: flake8 Lint + uses: reviewdog/action-flake8@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2999f3f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Upload Python Package + +on: + release: + types: [published] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + - name: Build package + run: python -m build --sdist --wheel + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml new file mode 100644 index 0000000..3ab9a16 --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,60 @@ +name: Unit tests + +on: + push: + branches: + - main + - dev + pull_request: + branches: + - main + paths-ignore: + - 'docs/**' + - 'devtools/**' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + unit_tests: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + - name: Test with pytest + run: | + pwd + lscpu + python -m pytest -v --durations=0 --cov-report xml:cov.xml --cov-config=setup.cfg --cov=quadax/ --db ./prof.db + - name: save coverage file and plot comparison results + if: always() + uses: actions/upload-artifact@v3 + with: + name: unit_test_artifact + path: | + ./cov.xml + ./prof.db + - name: Upload coverage + id : codecov + uses: Wandalen/wretry.action@v1.0.36 + with: + action: codecov/codecov-action@v3 + with: | + token: ${{ secrets.CODECOV_TOKEN }} + name: codecov-umbrella + files: ./cov.xml + fail_ci_if_error: true + verbose: true + attempt_limit: 10 + attempt_delay: 60000 # ms, 1 min