Skip to content

Commit

Permalink
fix: gh actions workflow
Browse files Browse the repository at this point in the history
- disables pip auto version check
- installs project in editable
- build package in virtual environment
- move env and permissions to individual job scope
- use `.venv/bin` instead of `.venv/Scripts` in Linux
  • Loading branch information
yozachar committed Aug 7, 2023
1 parent 8fb3bf7 commit 3708dac
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ on:
workflow_dispatch:
push:
branches: ["master"]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
env:
BUILD_PATH: "."
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
env:
BUILD_PATH: .
PIP_DISABLE_PIP_VERSION_CHECK: 1
steps:
# checkout repository
- name: Checkout repository
Expand All @@ -28,7 +23,9 @@ jobs:
python-version: "3.11"
# building
- name: Install 'documentation' dependencies
run: pip install -r python/requirements.mkdocs.txt
run: |
pip install .
pip install -r python/requirements.mkdocs.txt
- name: Build documentation
run: python src/export docs
# set up Pages
Expand All @@ -40,13 +37,17 @@ jobs:
with:
path: ${{ env.BUILD_PATH }}/site
deploy:
runs-on: ubuntu-latest
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# deploy documentation
name: Deploy
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v1
id: deployment
uses: actions/deploy-pages@v2
26 changes: 16 additions & 10 deletions .github/workflows/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ on:
workflow_dispatch:
release:
types: [published]
permissions:
contents: read
env:
BUILD_PATH: "."
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
env:
BUILD_PATH: .
PIP_DISABLE_PIP_VERSION_CHECK: 1
steps:
# checkout repository
- name: Checkout repository
Expand All @@ -24,21 +25,26 @@ jobs:
- name: Install dependencies
run: |
python -m venv .venv
./.venv/Scripts/python -m pip install --upgrade pip
./.venv/Scripts/pip install .
./.venv/Scripts/pip install -r python/requirements.sphinx.txt
./.venv/Scripts/pip install build
./.venv/bin/python -m pip install --upgrade pip
./.venv/bin/pip install .
./.venv/bin/pip install -r python/requirements.sphinx.txt
./.venv/bin/pip install build
# build package
- name: Build package
run: ./.venv/Scripts/python src/export package
run: |
. ./.venv/bin/activate
python src/export package
deactivate
# upload package as artifact
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ${{ env.BUILD_PATH }}/dist
publish:
runs-on: ubuntu-latest
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# download artifact
- name: Download artifact
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/pycqa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
jobs:
tooling:
runs-on: ubuntu-latest
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
steps:
# checkout repository
- name: Checkout repository
Expand All @@ -20,7 +22,9 @@ jobs:
python-version: "3.8"
# tooling
- name: Install 'tooling' dependencies
run: pip install -r python/requirements.tooling.txt
run: |
pip install .
pip install -r python/requirements.tooling.txt
- name: Tooling
run: |
black .
Expand Down
2 changes: 1 addition & 1 deletion src/export/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def package(source: Path):
generate_documentation(source, only_rst_man=True)
# print()
if getenv("CI", "false") == "true":
process = Popen(("./venv/Scripts/python", "-m", "build"), shell=False) # nosec
process = Popen(("./.venv/bin/python", "-m", "build"), shell=False) # nosec
else:
process = Popen(("pdm", "build"), shell=False) # nosec
process.communicate()
Expand Down

0 comments on commit 3708dac

Please sign in to comment.