diff --git a/.github/workflows/stefflow.yml b/.github/workflows/stefflow.yml new file mode 100644 index 00000000..407e6941 --- /dev/null +++ b/.github/workflows/stefflow.yml @@ -0,0 +1,166 @@ +name: "๐Ÿ”จ Steffo's Python Poetry Workflow" + +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + schedule: + - cron: "13 10 * * 1" # Every monday at 10:10 AM + release: + types: + - published + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + analyze-codeql: + name: "๐Ÿ” Perform CodeQL analysis" + runs-on: ubuntu-latest + if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} + + permissions: + security-events: write + actions: read + contents: read + + steps: + - name: "โฌ‡๏ธ Checkout repository" + uses: actions/checkout@v3 + + - name: "๐Ÿ”จ Initialize CodeQL" + uses: github/codeql-action/init@v1 + with: + languages: python + + - name: "๐Ÿ” Perform CodeQL analysis" + uses: github/codeql-action/analyze@v1 + + analyze-pytest: + name: "๐Ÿงช Test package" + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} + + services: + postgres: + image: postgres + env: + POSTGRES_USER: username + POSTGRES_PASSWORD: password + POSTGRES_DB: db + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - "5432:5432" + + steps: + - name: "โฌ‡๏ธ Checkout repository" + uses: actions/checkout@v3 + + - name: "๐Ÿ”จ Setup Python" + uses: actions/setup-python@v3 + + - name: "๐Ÿ”จ Setup Poetry" + uses: abatilo/actions-poetry@v2.1.4 + + - name: "๐Ÿ”จ Setup Poetry Python environment" + id: pyenv + uses: Steffo99/actions-poetry-deps@0.2.3 + + - name: "๐Ÿงช Run tests" + run: | + source ${{ steps.pyenv.outputs.pyenv }}/activate + pytest --verbose --cov=. --cov-report=html + + - name: "โฌ†๏ธ Upload coverage" + uses: actions/upload-artifact@v2 + with: + name: "code-coverage-report" + path: htmlcov + + build-package: + name: "๐Ÿ“ฆ Build and publish Python package" + runs-on: ubuntu-latest + if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }} + + steps: + - name: "โฌ‡๏ธ Checkout repository" + uses: actions/checkout@v3 + + - name: "๐Ÿ”จ Setup Python" + uses: actions/setup-python@v3 + + - name: "๐Ÿ”จ Setup Poetry" + uses: abatilo/actions-poetry@v2.1.4 + + - name: "๐Ÿ”จ Setup Poetry Python environment" + uses: Steffo99/actions-poetry-deps@0.2.3 + + - name: "๐Ÿ— Build package with Poetry" + run: poetry build --no-interaction + + - name: "โฌ†๏ธ Upload code package as artifact" + uses: actions/upload-artifact@v2 + with: + name: "package.tar.gz" + path: dist/*.tar.gz + + - name: "โฌ†๏ธ Upload wheel package as artifact" + uses: actions/upload-artifact@v2 + with: + name: "package.whl" + path: dist/*.whl + + - name: "Publish Poetry package" + run: poetry publish --no-interaction + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} + + build-docs: + name: "๐Ÿ“” Build and publish documentation" + runs-on: ubuntu-latest + needs: build-package + if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }} + + steps: + - name: "โฌ‡๏ธ Checkout repository" + uses: actions/checkout@v3 + + - name: "๐Ÿ”จ Setup Python" + uses: actions/setup-python@v3 + + - name: "๐Ÿ”จ Setup Poetry" + uses: abatilo/actions-poetry@v2.1.4 + + - name: "๐Ÿ”จ Setup Poetry Python environment" + id: pyenv + uses: Steffo99/actions-poetry-deps@0.2.3 + + - name: "๐Ÿ— Build HTML documentation with Sphinx" + working-directory: docs/ + run: | + source ${{ steps.pyenv.outputs.pyenv }}/activate + make html + + - name: "โฌ†๏ธ Upload docs artifact" + uses: actions/upload-artifact@v2.3.1 + with: + name: "documentation" + path: "docs/build/html/" + + - name: "๐ŸŒ๏ธ Publish build to GitHub Pages" + uses: peaceiris/actions-gh-pages@v3.8.0 + with: + github_token: "${{ secrets.GITHUB_TOKEN }}" + publish_dir: "docs/build/html/" + enable_jekyll: false diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml deleted file mode 100644 index 297a4996..00000000 --- a/.github/workflows/test-package.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Test package - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - check: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v2 - - name: Install Python 3.9 - uses: actions/setup-python@v2 - with: - python-version: '3.9' - - name: Install Poetry - uses: abatilo/actions-poetry@v2.0.0 - - name: Install development dependencies - run: poetry install - - name: Run pytest - run: poetry run pytest