Generate JSON definitions & build #147
Workflow file for this run
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: Generate JSON definitions & build | |
run-name: Generate JSON definitions & build | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
env: | |
CONTAINER_NAME: json-container | |
jobs: | |
create: | |
runs-on: ubuntu-latest | |
name: Validate generated code | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Set environment variables | |
run: | | |
DISTRO=$(./ci/get-metadata.sh debian-distro) | |
PROXMOX_VE_VERSION=$(./ci/get-metadata.sh pve-version) | |
PACKAGES=$(./ci/get-metadata.sh packages | jq -r '.[0] | to_entries | map(.key + "=" + .value) | join(" ")') | |
echo "DISTRO=$DISTRO" >> "$GITHUB_ENV" | |
echo "PROXMOX_VE_VERSION=$PROXMOX_VE_VERSION" >> "$GITHUB_ENV" | |
echo "PACKAGES=$PACKAGES" >> "$GITHUB_ENV" | |
- name: Create container | |
run: | | |
docker create --mount "type=bind,source=./ci,target=/mnt" --name $CONTAINER_NAME debian:$DISTRO sleep infinity | |
docker start $CONTAINER_NAME | |
- name: Setup proxmox-ve ${{ env.PROXMOX_VE_VERSION }} on debian ${{ env.DISTRO }} | |
run: docker exec $CONTAINER_NAME /mnt/setup.sh $DISTRO | |
- name: Check if newer versions of specific packages are available | |
run: docker exec $CONTAINER_NAME /mnt/check-package-versions.sh $(echo $PACKAGES) | |
- name: Install all packages | |
run: docker exec $CONTAINER_NAME apt-get install -y $(echo $PACKAGES) | |
# Installing some packages comes with some errors | |
continue-on-error: true | |
- name: Generate JSON schema | |
run: docker exec $CONTAINER_NAME /usr/bin/bash -c "/mnt/dump-schema.pl > /mnt/PVE-schema.json" | |
- name: Save package versions | |
run: docker exec $CONTAINER_NAME /usr/bin/bash -c "apt list --installed | tee /mnt/packages.txt" | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts | |
path: | | |
./ci/PVE-schema.json | |
./ci/packages.txt | |
- name: Generate the client | |
run: cargo run --manifest-path generator/Cargo.toml -- recursive ./ci/PVE-schema.json proxmox-api/src/generated.rs | |
- name: Format the generated client | |
run: cargo fmt --manifest-path ./proxmox-api/Cargo.toml -- ./proxmox-api/src/generated.rs | |
- name: Assert empty git diff | |
run: ./ci/assert-empty-git-diff.sh | |
- name: Show line count | |
run: wc -l ./ci/PVE-schema.json | |
check-and-build: | |
strategy: | |
matrix: | |
definition: | |
- name: "library" | |
args: "--lib" | |
manifest: proxmox-api/Cargo.toml | |
- name: "CLI tool" | |
args: "--bin proxmox-api --features cli" | |
manifest: proxmox-api/Cargo.toml | |
- name: "library with just the reqwest client" | |
args: "--lib --no-default-features --features reqwest-client" | |
manifest: proxmox-api/Cargo.toml | |
- name: generator | |
manifest: generator/Cargo.toml | |
name: Build & check the ${{ matrix.definition.name }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Validate the formatting | |
run: cargo fmt --manifest-path ${{ matrix.definition.manifest }} --check | |
- name: Check the ${{ matrix.definition.name }} | |
run: cargo check --locked --manifest-path ${{ matrix.definition.manifest }} ${{ matrix.definition.args }} | |
# TODO: reenable this for merges to main? | |
- name: Build the ${{ matrix.definition.name }} | |
run: cargo build --locked --manifest-path ${{ matrix.definition.manifest }} ${{ matrix.definition.args }} |