Skip to content

Commit 7a46db6

Browse files
authored
Merge pull request #47 from xcp-ng/gln/cli-refactor-improve-qskr
2 parents e9cafe6 + ba4edca commit 7a46db6

File tree

17 files changed

+600
-84
lines changed

17 files changed

+600
-84
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Setup UV and Sync
2+
description: 'Install uv and sync the dependencies'
3+
inputs:
4+
sync:
5+
description: 'Whether to run `uv sync` after setting up.'
6+
required: false
7+
default: 'true'
8+
type: boolean
9+
dev:
10+
description: 'Whether to use `--no-dev` with `uv sync`.'
11+
required: false
12+
default: 'true'
13+
type: boolean
14+
activate-environment:
15+
description: 'Wether to activate the virtual env or not'
16+
required: false
17+
default: true
18+
type: boolean
19+
runs:
20+
using: 'composite'
21+
steps:
22+
- uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
23+
with:
24+
version: "0.7.x"
25+
activate-environment: ${{ inputs.activate-environment }}
26+
- if: inputs.sync == 'true' && inputs.dev == 'false'
27+
run: uv sync --frozen --no-dev
28+
shell: bash
29+
env:
30+
FORCE_COLOR: "1"
31+
- if: inputs.sync == 'true' && inputs.dev == 'true'
32+
run: uv sync --frozen
33+
shell: bash
34+
env:
35+
FORCE_COLOR: "1"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Static code checkers
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
pull_request:
8+
9+
permissions: {}
10+
11+
jobs:
12+
mypy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
persist-credentials: false
18+
- uses: ./.github/actions/uv-setup/
19+
- run: mypy --install-types --non-interactive .
20+
21+
pyright:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
persist-credentials: false
27+
- uses: ./.github/actions/uv-setup/
28+
- run: pyright
29+
30+
ruff:
31+
runs-on: ubuntu-latest
32+
env:
33+
FORCE_COLOR: "1"
34+
steps:
35+
- uses: actions/checkout@v4
36+
with:
37+
persist-credentials: false
38+
- uses: ./.github/actions/uv-setup/
39+
- run: ruff check
40+
41+
flake8:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
persist-credentials: false
47+
- uses: ./.github/actions/uv-setup/
48+
- run: flake8

.github/workflows/docker.yml

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
name: Build and Push Docker Image to GHCR
22

3-
on: push
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
pull_request:
48

5-
permissions:
6-
contents: read # Required to checkout the repo code
7-
packages: write # Required to push packages to GHCR
9+
permissions: {}
810

911
jobs:
1012
xcp-ng-build-env-82:
1113
runs-on: ubuntu-latest
14+
permissions:
15+
packages: write # Required to push packages to GHCR
1216
steps:
1317
- uses: actions/checkout@v4
14-
- uses: docker/setup-buildx-action@v3
18+
with:
19+
persist-credentials: false
20+
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
1521
with:
1622
driver: docker-container
17-
- uses: docker/login-action@v3
23+
- uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1
1824
if: github.ref == 'refs/heads/master'
1925
with:
2026
registry: ghcr.io
2127
username: ${{ github.actor }} # Uses the GitHub user/org name that triggered the workflow
2228
password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub
23-
- uses: docker/build-push-action@v5 # Using v5 for latest features
29+
- uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
2430
with:
2531
context: ./src/xcp_ng_dev/
2632
file: ./src/xcp_ng_dev/files/Dockerfile-8.x
@@ -35,18 +41,23 @@ jobs:
3541
3642
xcp-ng-build-env-83:
3743
runs-on: ubuntu-latest
44+
permissions:
45+
packages: write # Required to push packages to GHCR
3846
steps:
3947
- uses: actions/checkout@v4
40-
- uses: docker/setup-buildx-action@v3
48+
with:
49+
persist-credentials: false
50+
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
4151
with:
4252
driver: docker-container
43-
- uses: docker/login-action@v3
53+
- uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1
4454
if: github.ref == 'refs/heads/master'
4555
with:
4656
registry: ghcr.io
4757
username: ${{ github.actor }} # Uses the GitHub user/org name that triggered the workflow
4858
password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub
49-
- uses: docker/build-push-action@v5 # Using v5 for latest features
59+
- run: echo "VERSION=$(cat ./src/xcp_ng_dev/files/protocol-version.txt | tr -d '\n')" >> $GITHUB_ENV
60+
- uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
5061
with:
5162
context: ./src/xcp_ng_dev/
5263
file: ./src/xcp_ng_dev/files/Dockerfile-8.x
@@ -60,18 +71,22 @@ jobs:
6071
# TODO: uncomment once we have a public xcp-ng 9.0 repository
6172
# xcp-ng-build-env-90:
6273
# runs-on: ubuntu-latest
74+
# permissions:
75+
# packages: write # Required to push packages to GHCR
6376
# steps:
6477
# - uses: actions/checkout@v4
65-
# - uses: docker/setup-buildx-action@v3
78+
# with:
79+
# persist-credentials: false
80+
# - uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
6681
# with:
6782
# driver: docker-container
68-
# - uses: docker/login-action@v3
83+
# - uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1
6984
# if: github.ref == 'refs/heads/master'
7085
# with:
7186
# registry: ghcr.io
7287
# username: ${{ github.actor }} # Uses the GitHub user/org name that triggered the workflow
7388
# password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub
74-
# - uses: docker/build-push-action@v5 # Using v5 for latest features
89+
# - uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
7590
# with:
7691
# context: ./src/xcp_ng_dev/
7792
# file: ./src/xcp_ng_dev/files/Dockerfile-9.x

.github/workflows/format.yaml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/main.yaml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@ on:
66
- 'master'
77
pull_request:
88

9+
permissions: {}
10+
911
jobs:
1012
test:
1113
runs-on: ubuntu-latest
1214
steps:
13-
- uses: actions/checkout@v2
14-
- name: Install uv
15-
uses: astral-sh/setup-uv@v6
16-
with:
17-
version: "0.7.x"
18-
- name: Install dependencies
19-
run: uv sync --frozen
20-
- name: Test
21-
# use script to provide a tty (workaround of systematic "docker -t"?)
22-
shell: 'script -q -e -c "bash {0}"'
23-
run: |
24-
uv run ./test/test.sh
15+
- uses: actions/checkout@v4
16+
with:
17+
persist-credentials: true # required for git lfs
18+
- uses: ./.github/actions/uv-setup/
19+
- name: Test
20+
# use script to provide a tty (workaround of systematic "docker -t"?)
21+
shell: 'script -q -e -c "bash {0}"'
22+
run: |
23+
./test/test.sh

.github/workflows/release.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Create a release from tag
2+
3+
permissions: {}
4+
5+
on:
6+
push:
7+
tags:
8+
- '*'
9+
10+
jobs:
11+
build:
12+
name: Build and store python artifacts
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
persist-credentials: false
21+
22+
- uses: ./.github/actions/uv-setup/
23+
24+
- name: Build
25+
run: uv build
26+
27+
- name: Store python distribution artifacts
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: artifacts
31+
path: dist/
32+
33+
release:
34+
permissions:
35+
contents: write # allow creating a release
36+
37+
name: "Create and package a release"
38+
runs-on: ubuntu-latest
39+
needs: [build]
40+
steps:
41+
- name: Retrieve distribution artifacts
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: artifacts
45+
path: dist/
46+
47+
- name: Create release ${{ github.ref_name }}
48+
shell: bash
49+
run: |
50+
gh release create ${GITHUB_REF_NAME} --repo ${{ github.repository }} --generate-notes dist/*
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Check requirements file consistency
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
pull_request:
8+
9+
permissions: {}
10+
11+
jobs:
12+
requirements-check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
persist-credentials: false
18+
- uses: ./.github/actions/uv-setup/
19+
with:
20+
dev: false
21+
- run: ./requirements/update_requirements.py
22+
- run: git diff --exit-code

.github/workflows/zizmor.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: GitHub Actions Security Analysis with zizmor 🌈
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
pull_request:
8+
9+
permissions: {}
10+
11+
jobs:
12+
zizmor:
13+
name: zizmor latest
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
persist-credentials: false
19+
- uses: ./.github/actions/uv-setup/
20+
with:
21+
sync: false
22+
- run: uvx zizmor --color=always .
23+
env:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11.11

0 commit comments

Comments
 (0)