update #46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: First Workflow | |
on: | |
push: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- main | |
- "dev-*" | |
paths-ignore: | |
- ".github/workflows/*" | |
jobs: | |
PR-Verification: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get code | |
uses: actions/checkout@v4 | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
export PATH="$HOME/.local/bin:$PATH" | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-poetry- | |
- name: Install dependencies | |
run: | | |
poetry install -v | |
- name: Black formatting check | |
run: | | |
poetry run black --check . | |
- name: Isort check | |
run: | | |
poetry run isort --check . | |
- name: Unit tests | |
id: unit_tests | |
continue-on-error: true | |
run: | | |
poetry run pytest -v > test_results.txt | |
- name: Upload test results | |
if: failure() && steps.unit_tests.outcome == 'failure' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Pytest-results | |
path: test_results.txt | |
Build: | |
needs: PR-Verification | |
runs-on: ubuntu-latest | |
outputs: | |
build_output: ${{ steps.set_output.outputs.build_result }} | |
steps: | |
- name: Restore cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-poetry- | |
- name: Pretend to build | |
id: set_output | |
run: | | |
echo "Building the project" | |
echo "::set-output name=build_result::successful" | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
export PATH="$HOME/.local/bin:$PATH" | |
- name: Install dependencies | |
run: | | |
poetry install -v | |
Deploy: | |
needs: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Pretend to deploy | |
run: echo "Deploying the project" | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: Pytest-results | |
path: test_results.txt | |
- name: List results | |
run: | | |
ls -als | |
cat test_results.txt | |
echo "The build result was: ${{ needs.Build.outputs.build_output }}" | |
Report: | |
needs: [PR-Verification, Build, Deploy] | |
if: failure() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Failure report | |
run: | | |
echo "The build failed. Please check the logs." | |
echo "$ {{ toJSON(github) }}" |