Skip to content

Commit 31cb3bf

Browse files
committed
ci: Update workflows
Signed-off-by: Kostis Papazafeiropoulos <papazof@gmail.com>
1 parent 9e0ece0 commit 31cb3bf

9 files changed

Lines changed: 380 additions & 201 deletions

File tree

.github/actions/build/action.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build Project
2+
description: Build and install project
3+
4+
inputs:
5+
# ignored
6+
coverage:
7+
default: 'false'
8+
# ignored
9+
options:
10+
default: ''
11+
# ignored
12+
prefix:
13+
default: ${{ github.workspace }}/opt
14+
# ignored
15+
pkgconfig-prefix:
16+
default: ''
17+
build-path:
18+
default: 'build'
19+
source-path:
20+
default: '.'
21+
# ignored
22+
build-type:
23+
default: 'plain'
24+
# ignored
25+
build:
26+
default: ''
27+
install:
28+
default: 'false'
29+
dist:
30+
default: 'false'
31+
# ignored
32+
subprojects:
33+
default: 'true'
34+
# ignored
35+
dist-tests:
36+
default: 'false'
37+
# ignored
38+
install-deb:
39+
default: 'false'
40+
41+
outputs:
42+
dist-path:
43+
value: ${{ steps.build.outputs.dist-path }}
44+
45+
runs:
46+
using: composite
47+
steps:
48+
- name: Create python virtual env
49+
working-directory: ${{ inputs.source-path }}
50+
run: |
51+
sudo apt-get update
52+
sudo apt-get install -y python3-venv libffi-dev
53+
python3 -m venv .venv
54+
shell: bash
55+
56+
- name: Install dependencies
57+
working-directory: ${{ inputs.source-path }}
58+
run: |
59+
./.venv/bin/pip install --upgrade pip
60+
./.venv/bin/pip install build
61+
shell: bash
62+
63+
- name: Build project
64+
working-directory: ${{ inputs.source-path }}
65+
if: ${{ inputs.dist == 'true' }}
66+
run: |
67+
./.venv/bin/python3 -m build -o "${{ inputs.build-path }}"
68+
echo "dist-path=${{ inputs.source-path }}/dist" >> "$GITHUB_OUTPUT"
69+
shell: bash
70+
71+
- name: Install project
72+
working-directory: ${{ inputs.source-path }}
73+
if: ${{ inputs.install == 'true' }}
74+
run: ./.venv/bin/pip install .
75+
shell: bash
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Run Tests
2+
description: Run project tests and generate coverage report
3+
4+
inputs:
5+
build-path:
6+
default: 'build'
7+
source-path:
8+
default: '.'
9+
# ignored
10+
valgrind:
11+
default: 'false'
12+
coverage:
13+
default: 'false'
14+
# ignored
15+
gcov:
16+
default: 'gcov'
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- name: Install dependencies
22+
working-directory: ${{ inputs.source-path }}
23+
run: |
24+
# FIXME: This should be in the vaccel coverage workflow
25+
if ! dpkg -s vaccel &> /dev/null; then
26+
wget "https://s3.nbfc.io/nbfc-assets/github/vaccel/rev/main/x86_64/release/vaccel_latest_amd64.deb"
27+
sudo apt install ./vaccel_latest_amd64.deb
28+
rm vaccel_latest_amd64.deb
29+
fi
30+
./.venv/bin/pip install .[test]
31+
shell: bash
32+
33+
- name: Run tests
34+
working-directory: ${{ inputs.source-path }}
35+
run: ./.venv/bin/python3 -m pytest
36+
shell: bash
37+
38+
- name: Calculate coverage
39+
working-directory: ${{ inputs.source-path }}
40+
if: ${{ inputs.coverage == 'true' }}
41+
run: |
42+
./.venv/bin/pip install tomli
43+
pkg_name=$(./.venv/bin/python3 -c \
44+
"import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['name'])")
45+
./.venv/bin/python3 -m pytest \
46+
--cov-report term \
47+
--cov-report xml:"${{ inputs.build-path }}/coverage.xml" \
48+
--cov="${pkg_name}" tests/
49+
shell: bash
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Generate API Reference
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
actions-repo:
7+
type: string
8+
default: 'nubificus/vaccel'
9+
actions-rev:
10+
type: string
11+
default: 'main'
12+
deploy:
13+
type: boolean
14+
default: false
15+
target-repo-owner:
16+
type: string
17+
default: 'nubificus'
18+
target-repo-name:
19+
type: string
20+
default: 'vaccel-docs_test'
21+
target-workflow:
22+
type: string
23+
default: 'dispatch-update-external-repo.yml'
24+
default: 'dispatch-update-external-repo.yml'
25+
secrets:
26+
GIT_CLONE_PAT:
27+
required: false
28+
29+
jobs:
30+
generate-reference:
31+
name: Generate API Reference
32+
runs-on: [base-dind-2204-amd64]
33+
permissions:
34+
contents: write
35+
36+
steps:
37+
- name: Checkout .github directory
38+
uses: actions/checkout@v4
39+
with:
40+
sparse-checkout: .github
41+
repository: ${{ inputs.actions-repo }}
42+
ref: ${{ inputs.actions-rev }}
43+
44+
- name: Initialize workspace
45+
uses: ./.github/actions/initialize-workspace
46+
with:
47+
submodules: 'false'
48+
remote-actions-repo: ${{ inputs.actions-repo }}
49+
token: ${{ secrets.GIT_CLONE_PAT || github.token }}
50+
fetch-depth: 0
51+
52+
- name: Determine SHA and branch
53+
id: get-rev-info
54+
uses: ./.github/actions/get-revision-info
55+
56+
- name: Generate vaccel-bot token
57+
id: generate-token
58+
uses: actions/create-github-app-token@v1
59+
with:
60+
app-id: ${{ vars.VACCEL_BOT_APP_ID }}
61+
private-key: ${{ secrets.VACCEL_BOT_PRIVATE_KEY }}
62+
63+
- name: Generate request metadata
64+
id: generate-meta
65+
run: |
66+
id="${{ github.repository }}-$(date +%s)"
67+
echo "trigger-id=${id}" | tee -a "$GITHUB_OUTPUT"
68+
json_metadata=$(jq -nc \
69+
--arg id '${{ steps.generate-meta.outputs.trigger-id }}' \
70+
--arg rev '${{ steps.get-rev-info.outputs.branch }}' \
71+
--arg repo '${{ github.repository }}' \
72+
--arg deploy '${{ inputs.deploy }}' \
73+
'{"trigger-id": $id, rev: $rev, repo: $repo, deploy: $deploy}')
74+
echo "trigger-meta=${json_metadata}" | tee -a "$GITHUB_OUTPUT"
75+
76+
# - name: Trigger docs update
77+
# id: trigger-update
78+
# uses: codex-/return-dispatch@v2
79+
# with:
80+
# token: ${{ steps.generate-token.outputs.token }}
81+
# ref: ci_add_python_api_reference
82+
# owner: ${{ inputs.target-repo-owner }}
83+
# repo: ${{ inputs.target-repo-name }}
84+
# workflow: ${{ inputs.target-workflow }}
85+
# workflow_inputs: ${{ steps.generate-meta.outputs.trigger-meta }}
86+
# workflow_timeout_seconds: 10 # Default: 300
87+
# distinct_id: ${{ steps.generate-meta.outputs.trigger-id }}
88+
#
89+
# - name: Wait for remote workflow result
90+
# uses: codex-/await-remote-run@v1
91+
# with:
92+
# token: ${{ steps.generate-token.outputs.token }}
93+
# owner: ${{ inputs.target-repo-owner }}
94+
# repo: ${{ inputs.target-repo-name }}
95+
# run_id: ${{ steps.trigger-update.outputs.run_id }}
96+
97+
- name: Trigger docs update
98+
id: trigger-update
99+
uses: nick-fields/retry@v3
100+
with:
101+
timeout_seconds: 5
102+
max_attempts: 6
103+
command: |
104+
id="${{ github.repository }}-$(date +%s)"
105+
curl -X POST \
106+
-H "Accept: application/vnd.github+json" \
107+
-H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \
108+
https://api.github.com/repos/${{ inputs.target-repo-owner }}/${{ inputs.target-repo-name }}/dispatches \
109+
-d '{
110+
"event_type": "update-external-repo",
111+
"client_payload": {
112+
"id": "${id)"
113+
"rev": "${{ steps.get-rev-info.outputs.branch }}",
114+
"repo": "${{ github.repository }}",
115+
"deploy": "${{ inputs.deploy }}"
116+
}
117+
}'
118+
echo "trigger-id=${id}" | tee -a "$GITHUB_OUTPUT"
119+
#
120+
# - name: Get remote workflow ID
121+
# id: get-remote-id
122+
# uses: nick-fields/retry@v3
123+
# with:
124+
# timeout_seconds: 5
125+
# max_attempts: 6
126+
# command: |
127+
# run_json=$(curl -s \
128+
# -H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \
129+
# "https://api.github.com/repos/nubificus/vaccel-docs/actions/runs?event=repository_dispatch")
130+
# run_id=$(echo "$run_json" | \
131+
# jq -r --arg tid "${{ steps.gen.outputs.trigger-id }}" '.workflow_runs[] | select(.run_name | contains($tid) | .id' | \
132+
# head -n 1)
133+
# if [ -z "$run_id" ] || [ "$run_id" = "null" ]; then
134+
# echo "Remote run ID not available. Retrying."
135+
# exit 1
136+
# else
137+
# echo "Got remote ID"
138+
# echo "remote-id=${run_id}" | tee -a "$GITHUB_OUTPUT"
139+
# break
140+
# fi
141+
#
142+
# - name: Wait for remote workflow result
143+
# uses: codex-/await-remote-run@v1
144+
# with:
145+
# token: ${{ steps.generate-token.outputs.token }}
146+
# owner: nubificus
147+
# repo: vaccel-docs
148+
# run_id: ${{ steps.get-remote-id.outputs.remote-id }}

.github/workflows/generate_docs.yml

Lines changed: 0 additions & 73 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Build and Upload
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build-dist:
15+
name: Build and Upload
16+
uses: nubificus/vaccel/.github/workflows/verify-build.yml@main
17+
with:
18+
release: true
19+
package: 'python'
20+
options: ''
21+
upload-subpath: 'python'
22+
secrets: inherit

0 commit comments

Comments
 (0)