Skip to content

Commit

Permalink
Simplify codebase and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
lampajr committed Mar 22, 2024
1 parent 3adb58e commit 46ff8ce
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 4,752 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/check-openapi-change.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This workflow will fetch the new openapi from the provided branch of https://github.com/Hyperfoil/Horreum and based on
# that it will re-generate the Horreum raw client and check the build/tests are still working.
# It could be tested running `gh act workflow_dispatch -e ./test/workflow_dispatch_event_example.json`. Remember to
# comment out the pull request creation :)
name: Update Horreum auto-generated client

on:
workflow_dispatch:
inputs:
branch:
description: Branch or tag of https://github.com/Hyperfoil/Horreum
required: true
# this event should be triggered by Horreum repo using peter-evans/repository-dispatch@v2
repository_dispatch:
types: [ detected-horreum-openapi-change ]

jobs:
check-openapi-change:
# TODO: find a way to set name including the branch we are checking
runs-on: ubuntu-latest
steps:
- name: Fetch Horreum branch
id: fetch-horreum-branch
run: |
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
echo "horreum_branch=${{ github.event.client_payload.branch }}" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "horreum_branch=${{ github.event.inputs.branch }}" >> $GITHUB_OUTPUT
else
echo "Unknown event: ${{ github.event_name }}"
exit 1
fi
- name: Fetch client branch
id: fetch-client-branch
run: |
if [ "${{ steps.fetch-horreum-branch.outputs.horreum_branch }}" = "master" ]; then
echo "horreum_client_branch=main" >> $GITHUB_OUTPUT
else
echo "horreum_client_branch=${{ steps.fetch-horreum-branch.outputs.horreum_branch }}" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v4
with:
ref: ${{ steps.fetch-client-branch.outputs.horreum_client_branch }}
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Generate horreum client
run: make HORREUM_BRANCH=${{ steps.fetch-horreum-branch.outputs.horreum_branch }} generate
- name: Install poetry
run: |
pipx install --pip-args=--constraint=./dev-constraints.txt poetry
poetry --version
- name: Build python library
run: poetry build
- name: Test horreum library
run: pytest test/horreum_client_test.py
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Generate horreum client
run: make generate
- name: Install poetry
run: |
pipx install --pip-args=--constraint=./dev-constraints.txt poetry
poetry --version
- name: Install dependencies
run: poetry install
- name: Build python library
run: poetry build
- name: Test horreum library
run: poetry run pytest test/horreum_client_test.py
3 changes: 2 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
publish:
name: ${{ matrix.session }} ${{ matrix.python }}
name: Publish horreum package
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
Expand All @@ -37,6 +37,7 @@ jobs:
exit 1
fi
- name: Build python library
# HORREUM_BRANCH must be properly set to the Horreum branch you want to fetch the openapi
run: make generate && poetry build --ansi
- name: Publish package on PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
48 changes: 0 additions & 48 deletions .github/workflows/update-client.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ bin/

# Kiota
**/.kiota.log

# Openapi
openapi/openapi.yaml
6 changes: 6 additions & 0 deletions docs/GET_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ pip install -r dev-constraints.txt

Once all dependencies are installed simply build the `whl` by running:

```bash
make generate
```

to generate source files and

```bash
poetry build
```
Expand Down
Empty file added openapi/.gitkeep
Empty file.
Loading

0 comments on commit 46ff8ce

Please sign in to comment.