From c5ee330e054d35ed863ea0d00880e2c47291cf78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20Nie=C3=9Fer?= <104903134+Y0dler@users.noreply.github.com> Date: Mon, 4 Dec 2023 11:22:12 +0100 Subject: [PATCH] Adapt pipeline to GitHub --- .github/dependabot.yml | 12 +++++++++++ .github/workflows/pre-commit.yml | 14 +++++++++++++ .github/workflows/release.yml | 36 ++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 36 ++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..9761439 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + # Keep Python dependencies updated + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "weekly" \ No newline at end of file diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..90a73bf --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,14 @@ +name: pre-commit + +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + - uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..06a534d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +name: release-pipeline + +on: + release: + types: + - created + + +jobs: + release-job: + runs-on: ubuntu-latest + env: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Build package + run: | + pip install twine wheel + python setup.py bdist_wheel + - name: Check version number match + run: | + echo "GITHUB_REF: ${GITHUB_REF}" + # Make sure the package version is the same as the tag + grep -Rq "^Version: ${GITHUB_REF:11}$" peak_performance.egg-info/PKG-INFO + - name: Publish to PyPI + run: | + twine check dist/* + twine upload --repository pypi --username __token__ --password ${PYPI_TOKEN} dist/* + - name: Test installation + run: | + sleep 120 + pip install peak_performance==${GITHUB_REF:11} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..c4c1904 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,36 @@ +name: pipeline + +on: + pull_request: + push: + branches: [main] + +jobs: + test-job: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install -e .[test] + - name: Run tests + run: | + pytest -v --cov-report xml --cov=peak_performance --cov-report term-missing peak_performance + - name: Upload coverage + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + - name: Test Wheel build, install and import + run: | + python setup.py bdist_wheel + twine check dist/* + cd dist + pip install peak_performance*.whl + python -c "import peak_performance; print(peak_performance.__version__)"