From f7aee9f3cda6f3ee0008324486305728dbcd0937 Mon Sep 17 00:00:00 2001 From: Santiago Martinez Date: Wed, 31 Jan 2024 20:08:15 +0000 Subject: [PATCH] Update workflows --- .github/workflows/build_frontend.yml | 27 +++++++ .github/workflows/build_user_guide.yml | 27 +++++++ .github/workflows/bundle.yml | 48 +++++++---- .github/workflows/bundle_test.yml | 60 ++++++++------ .github/workflows/docs.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/publish.yml | 108 +++++++++++++++++++++++++ .github/workflows/test.yml | 11 ++- 8 files changed, 243 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/build_frontend.yml create mode 100644 .github/workflows/build_user_guide.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/build_frontend.yml b/.github/workflows/build_frontend.yml new file mode 100644 index 00000000..6299d42d --- /dev/null +++ b/.github/workflows/build_frontend.yml @@ -0,0 +1,27 @@ +name: Build Frontend + +on: + workflow_call: + +jobs: + build-frontend: + name: Build Frontend + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 21 + - name: Install dependencies + run: | + cd front + npm install + - name: Build app + run: | + cd front + npm run build + - name: Upload build + uses: actions/upload-artifact@v4 + with: + name: frontend + path: front/out diff --git a/.github/workflows/build_user_guide.yml b/.github/workflows/build_user_guide.yml new file mode 100644 index 00000000..0fe868a4 --- /dev/null +++ b/.github/workflows/build_user_guide.yml @@ -0,0 +1,27 @@ +name: Build Frontend + +on: + workflow_call: + +jobs: + build-user-guide: + name: Build User Guide + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Install dependencies + run: | + cd back + pip install -r guide_requirements.txt + - name: Build Guide + run: | + cd back + mkdocs build -d mkdocs-guide.yml -d site + - name: Upload build + uses: actions/upload-artifact@v4 + with: + name: user_guide + path: back/site diff --git a/.github/workflows/bundle.yml b/.github/workflows/bundle.yml index d830b13a..d6df6d13 100644 --- a/.github/workflows/bundle.yml +++ b/.github/workflows/bundle.yml @@ -4,20 +4,28 @@ on: types: [published] jobs: + build-user-guide: + uses: mbsantiago/whombat/.github/workflows/build_user_guide.yml@dev + + build-frontend: + uses: mbsantiago/whombat/.github/workflows/build_frontend.yml@dev + build-windows: runs-on: windows-latest + needs: [build-user-guide, build-frontend] steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: "3.11" - - uses: actions/setup-node@v4 + - uses: actions/download-artifact@v4 with: - node-version: 21 - - shell: pwsh - run: scripts/update_front.ps1 - - shell: pwsh - run: scripts/update_guide.ps1 + name: frontend + path: back/src/whombat/statics/ + - uses: actions/download-artifact@v4 + with: + name: user_guide + path: back/src/whombat/user_guide/ - shell: pwsh run: scripts/bundle_windows.ps1 - run: | @@ -30,17 +38,20 @@ jobs: build-ubuntu: runs-on: ubuntu-20.04 + needs: [build-user-guide, build-frontend] steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: "3.11" - - uses: actions/setup-node@v4 + - uses: actions/download-artifact@v4 with: - node-version: 21 - - run: npm cache clean --force - - run: make build-frontend - - run: make build-guide + name: frontend + path: back/src/whombat/statics/ + - uses: actions/download-artifact@v4 + with: + name: user_guide + path: back/src/whombat/user_guide/ - run: bash scripts/bundle_linux.sh - run: | mkdir dist/ @@ -52,16 +63,23 @@ jobs: build-macos: runs-on: macos-11 + needs: [build-user-guide, build-frontend] steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: "3.11" - - uses: actions/setup-node@v4 + - uses: actions/setup-python@v4 + with: + python-version: "3.11" + - uses: actions/download-artifact@v4 + with: + name: frontend + path: back/src/whombat/statics/ + - uses: actions/download-artifact@v4 with: - node-version: 21 - - run: make build-frontend - - run: make build-guide + name: user_guide + path: back/src/whombat/user_guide/ - run: bash scripts/bundle_macos.sh - run: | mkdir dist/ diff --git a/.github/workflows/bundle_test.yml b/.github/workflows/bundle_test.yml index 8b658147..805db259 100644 --- a/.github/workflows/bundle_test.yml +++ b/.github/workflows/bundle_test.yml @@ -1,27 +1,34 @@ name: Test Bundle App -on: +on: workflow_dispatch: push: branches: - workflows - jobs: + build-user-guide: + uses: mbsantiago/whombat/.github/workflows/build_user_guide.yml@dev + + build-frontend: + uses: mbsantiago/whombat/.github/workflows/build_frontend.yml@dev + build-windows-test: runs-on: windows-latest + needs: [build-user-guide, build-frontend] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" - - uses: actions/setup-node@v4 + - uses: actions/download-artifact@v4 with: - node-version: 21 - - shell: pwsh - run: scripts/update_front.ps1 - - shell: pwsh - run: scripts/update_guide.ps1 + name: frontend + path: back/src/whombat/statics/ + - uses: actions/download-artifact@v4 + with: + name: user_guide + path: back/src/whombat/user_guide/ - shell: pwsh run: scripts/bundle_windows.ps1 - run: | @@ -34,17 +41,20 @@ jobs: build-ubuntu-test: runs-on: ubuntu-20.04 + needs: [build-user-guide, build-frontend] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" - - uses: actions/setup-node@v4 + - uses: actions/download-artifact@v4 with: - node-version: 21 - - run: npm cache clean --force - - run: make build-frontend - - run: make build-guide + name: frontend + path: back/src/whombat/statics/ + - uses: actions/download-artifact@v4 + with: + name: user_guide + path: back/src/whombat/user_guide/ - run: bash scripts/bundle_linux.sh - run: | mkdir dist/ @@ -56,16 +66,20 @@ jobs: build-macos-test: runs-on: macos-11 + needs: [build-user-guide, build-frontend] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" - - uses: actions/setup-node@v4 + - uses: actions/download-artifact@v4 + with: + name: frontend + path: back/src/whombat/statics/ + - uses: actions/download-artifact@v4 with: - node-version: 21 - - run: make build-frontend - - run: make build-guide + name: user_guide + path: back/src/whombat/user_guide/ - run: bash scripts/bundle_macos.sh - run: | mkdir dist/ diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 9d2815d1..5cd80970 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,7 +13,7 @@ jobs: matrix: python-version: ["3.11"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup PDM uses: pdm-project/setup-pdm@v3 with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a3872a38..d3fb48ff 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,7 +12,7 @@ jobs: matrix: python-version: ["3.11"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup PDM uses: pdm-project/setup-pdm@v3 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..2670ae63 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,108 @@ +name: Publish PyPI +on: + workflow_dispatch: + release: + types: [published] + +jobs: + build-user-guide: + uses: mbsantiago/whombat/.github/workflows/build_user_guide.yml@dev + + build-frontend: + uses: mbsantiago/whombat/.github/workflows/build_frontend.yml@dev + + build: + runs-on: ubuntu-latest + needs: [build-user-guide, build-frontend] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.11" + - uses: actions/download-artifact@v4 + with: + name: frontend + path: back/src/whombat/statics/ + - uses: actions/download-artifact@v4 + with: + name: user_guide + path: back/src/whombat/user_guide/ + - name: Install pypa/build + run: pip install build + - name: Build a binary wheel and source tarball + run: | + cd back + python -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: back/dist/ + + publish-to-pypi: + name: Publish to PyPI + needs: [build] + runs-on: ubuntu-latest + + if: github.event_name == 'release' + + environment: + name: pypi + url: https://pypi.org/p/whombat + + permissions: + id-token: write + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + name: Upload to GitHub release + needs: [publish-to-pypi] + runs-on: ubuntu-latest + + if: github.event_name == 'release' + + permissions: + contents: write + id-token: write + + steps: + - name: Download the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Upload artifact to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: | + gh release upload '${{ github.ref_name }}' dist/** --repo '${{github.repository }}' + + publish-to-testpypi: + name: Publish to TestPyPI + needs: [build] + runs-on: ubuntu-latest + + if: github.event_name == 'workflow_dispatch' + + environment: + name: testpypi + url: https://test.pypi.org/p/whombat + + permissions: + id-token: write + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 92cedbaa..174b7eba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: matrix: python-version: ["3.11"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup PDM uses: pdm-project/setup-pdm@v3 with: @@ -24,4 +24,11 @@ jobs: - name: Run tests run: | cd back - pdm run pytest tests/ + pdm run coverage run --source whombat -m pytest + pdm run coverage report -m + pdm run coverage html + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} +