diff --git a/.github/workflows/.tests-python.yml b/.github/workflows/.tests-python.yml index 0d303c052..6f53afeed 100644 --- a/.github/workflows/.tests-python.yml +++ b/.github/workflows/.tests-python.yml @@ -34,24 +34,31 @@ jobs: matrix: python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] steps: + - uses: actions/checkout@v4 + - name: Install Poetry and Dependencies run: | python -m pip install --upgrade pip pip install --quiet poetry poetry config virtualenvs.create false poetry install --no-interaction --quiet + - name: Create test databases run: python db/create_ci_test_db.py + - name: Bandit if: matrix.python-version == '3.13' run: bandit -r fittrackee -c pyproject.toml + - name: Lint if: matrix.python-version == '3.13' run: ruff check fittrackee e2e + - name: Mypy if: matrix.python-version == '3.13' run: mypy fittrackee + - name: Pytest run: pytest fittrackee -n auto --maxprocesses=2 -p no:warnings --cov fittrackee --cov-report term-missing --maxfail=1 @@ -74,15 +81,19 @@ jobs: matrix: psql-version: [ "12", "13", "14", "15", "16" ] steps: + - uses: actions/checkout@v4 + - name: Install Poetry and Dependencies run: | python -m pip install --upgrade pip pip install --quiet poetry poetry config virtualenvs.create false poetry install --no-interaction --quiet + - name: Create test databases run: python db/create_ci_test_db.py + - name: Pytest run: pytest fittrackee -n auto --maxprocesses=2 -p no:warnings --cov fittrackee --cov-report term-missing --maxfail=1 @@ -115,15 +126,19 @@ jobs: EMAIL_URL: "smtp://mailhog:1025" REDIS_URL: "redis://redis:6379" steps: + - uses: actions/checkout@v4 + - name: Install Poetry and Dependencies run: | python -m pip install --upgrade pip pip install --quiet poetry poetry config virtualenvs.create false poetry install --no-interaction --quiet + - name: Run migrations run: flask db upgrade --directory fittrackee/migrations + - name: Start application and run tests with Selenium run: | setsid nohup flask run --with-threads -h 0.0.0.0 -p 5000 >> nohup.out 2>&1 & @@ -191,3 +206,66 @@ jobs: uses: ./.github/workflows/.e2e-tests.yml with: previous-version: true + + publish-to-pypi: + if: github.repository == 'SamR1/FitTrackee' && startsWith(github.ref, 'refs/tags/v') + name: Publish Python distribution to PyPI + needs: ["end2end", "end2end_package", "end2end_package_update"] + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/fittrackee + permissions: + id-token: write + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + if: github.repository == 'SamR1/FitTrackee' && startsWith(github.ref, 'refs/tags/v') + name: Upload distribution to GitHub Release + needs: ["publish-to-pypi"] + runs-on: ubuntu-latest + + permissions: + contents: write + id-token: write + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v3.0.0 + with: + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + + - name: Create GitHub draft release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + "$GITHUB_REF_NAME" + --repo "$GITHUB_REPOSITORY" + --draft + --notes "wip" + + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release upload + "$GITHUB_REF_NAME" dist/** + --repo "$GITHUB_REPOSITORY"