From e6870e014ac5081561fe20ff10c2ac2f8042d281 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Thu, 29 Aug 2024 22:13:20 -0700 Subject: [PATCH] Create ci_cd.yml try to do automated testing and linting and optional pypi pushing to the repo --- .github/workflows/ci_cd.yml | 68 +++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/ci_cd.yml diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml new file mode 100644 index 0000000..bddac4c --- /dev/null +++ b/.github/workflows/ci_cd.yml @@ -0,0 +1,68 @@ +name: CI/CD + +on: + push: + branches: [ main ] + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8, 3.9, '3.10', '3.11'] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install poetry + poetry install + - name: Run tests + run: | + poetry run pytest + + lint: + 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: | + pip install poetry + poetry install + - name: Run linters + run: | + poetry run flake8 . + poetry run black --check . + + publish: + needs: [test, lint] + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install dependencies + run: | + pip install poetry + - name: Build and publish + env: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: | + poetry config pypi-token.pypi $PYPI_TOKEN + poetry build + poetry publish