From aa27ab855b4dfa2bdf9164de839651066ecbcfe5 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 8 May 2025 02:58:57 +0000 Subject: [PATCH] Add rpm package to workflow. Improve workflows. Signed-off-by: Jason Volk --- .github/workflows/lint.yml | 16 +++---- .github/workflows/main.yml | 23 +++++++-- .github/workflows/package.yml | 26 ++--------- .github/workflows/publish.yml | 73 +++++++++++++++++++++++++++++ .github/workflows/test.yml | 2 +- docker/Dockerfile.cargo.rpm | 52 +++++++++++++++++++++ docker/Dockerfile.ingredients | 4 -- docker/bake.hcl | 88 +++++++++++++++++++++++++++++++++-- docker/bake.sh | 9 ++-- docs/deploying/docker.md | 4 +- src/main/Cargo.toml | 10 ++++ 11 files changed, 260 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 docker/Dockerfile.cargo.rpm diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 928665b5..41cca7f6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -38,13 +38,13 @@ on: jobs: fmt: - if: ${{contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0]) && contains(fromJSON(inputs.feat_sets), fromJSON('["none"]')[0]) && contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])}} + if: ${{ !failure() && !cancelled() && contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0]) && contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0]) && contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0]) }} name: Format uses: ./.github/workflows/bake.yml with: bake_targets: '["fmt"]' cargo_profiles: '["test"]' - feat_sets: '["none"]' + feat_sets: '["all"]' rust_toolchains: '["nightly"]' rust_targets: ${{inputs.rust_targets}} sys_names: ${{inputs.sys_names}} @@ -55,13 +55,13 @@ jobs: includes: ${{inputs.includes}} audit: - if: ${{contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0]) && contains(fromJSON(inputs.feat_sets), fromJSON('["none"]')[0]) && contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])}} + if: ${{ !failure() && !cancelled() && contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0]) && contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0]) && contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0]) }} name: Audit uses: ./.github/workflows/bake.yml with: bake_targets: '["audit"]' cargo_profiles: '["test"]' - feat_sets: '["none"]' + feat_sets: '["all"]' rust_toolchains: '["nightly"]' sys_names: ${{inputs.sys_names}} sys_versions: ${{inputs.sys_versions}} @@ -72,13 +72,13 @@ jobs: includes: ${{inputs.includes}} lychee: - if: ${{contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0]) && contains(fromJSON(inputs.feat_sets), fromJSON('["none"]')[0]) && contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])}} + if: ${{ !failure() && !cancelled() && contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0]) && contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0]) && contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])}} name: Lychee uses: ./.github/workflows/bake.yml with: bake_targets: '["lychee"]' cargo_profiles: '["test"]' - feat_sets: '["none"]' + feat_sets: '["all"]' rust_toolchains: '["nightly"]' sys_names: ${{inputs.sys_names}} sys_versions: ${{inputs.sys_versions}} @@ -89,7 +89,7 @@ jobs: includes: ${{inputs.includes}} clippy: - if: ${{ always() }} + if: ${{ !failure() && !cancelled() }} name: Clippy needs: [fmt, audit, lychee] uses: ./.github/workflows/bake.yml @@ -107,7 +107,7 @@ jobs: includes: ${{inputs.includes}} doc: - if: ${{contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0]) && contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])}} + if: ${{ !failure() && !cancelled() && contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0]) && contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0]) }} name: Docs needs: [clippy] uses: ./.github/workflows/bake.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 34ebd19b..7fd6bf47 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ env: jobs: deps: - if: ${{vars.CI_VERBOSE_DEPS || false}} + if: ${{ vars.CI_VERBOSE_DEPS || false }} name: Deps uses: ./.github/workflows/deps.yml with: @@ -32,7 +32,7 @@ jobs: machines: ${{vars.MACHINES}} lint: - if: ${{ always() && !cancelled() }} + if: ${{ !failure() && !cancelled() }} name: Lint needs: [deps] uses: ./.github/workflows/lint.yml @@ -47,7 +47,7 @@ jobs: machines: ${{vars.MACHINES}} test: - if: ${{ always() && !cancelled() }} + if: ${{ !failure() && !cancelled() }} name: Test needs: [lint] uses: ./.github/workflows/test.yml @@ -63,7 +63,7 @@ jobs: complement: true package: - if: ${{ always() && !cancelled() }} + if: ${{ !failure() && !cancelled() }} name: Package needs: [test] uses: ./.github/workflows/package.yml @@ -76,3 +76,18 @@ jobs: rust_targets: ${{vars.RUST_TARGETS}} sys_targets: ${{vars.sys_TARGETS}} machines: ${{vars.MACHINES}} + + publish: + if: ${{ !failure() && !cancelled() }} + name: Publish + needs: [package] + uses: ./.github/workflows/publish.yml + with: + cargo_profiles: '["release"]' + feat_sets: ${{vars.FEAT_SETS}} + rust_toolchains: '["stable"]' + sys_names: ${{vars.SYS_NAMES}} + sys_versions: ${{vars.SYS_VERSIONS}} + rust_targets: ${{vars.RUST_TARGETS}} + sys_targets: ${{vars.sys_TARGETS}} + machines: ${{vars.MACHINES}} diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 2cdb3ee7..b4e36e2e 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -39,12 +39,13 @@ on: jobs: deb: + if: ${{ !failure() && !cancelled() && contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0]) }} name: Deb uses: ./.github/workflows/bake.yml with: bake_targets: '["pkg-deb-install"]' cargo_profiles: ${{inputs.cargo_profiles}} - feat_sets: ${{inputs.feat_sets}} + feat_sets: '["all"]' rust_toolchains: ${{inputs.rust_toolchains}} sys_names: ${{inputs.sys_names}} sys_versions: ${{inputs.sys_versions}} @@ -55,30 +56,13 @@ jobs: includes: ${{inputs.includes}} rpm: - if: false + if: ${{ !failure() && !cancelled() && contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0]) }} name: RPM uses: ./.github/workflows/bake.yml with: - bake_targets: '["pkg-rpm-install"]' + bake_targets: '["pkg-rpm"]' cargo_profiles: ${{inputs.cargo_profiles}} - feat_sets: ${{inputs.feat_sets}} - rust_toolchains: ${{inputs.rust_toolchains}} - sys_names: ${{inputs.sys_names}} - sys_versions: ${{inputs.sys_versions}} - rust_targets: ${{inputs.rust_targets}} - sys_targets: ${{inputs.sys_targets}} - machines: ${{inputs.machines}} - excludes: ${{inputs.excludes}} - includes: ${{inputs.includes}} - - dockerhub: - if: ${{github.ref == 'refs/heads/main'}} - name: DockerHub - uses: ./.github/workflows/bake.yml - with: - bake_targets: '["dockerhub"]' - cargo_profiles: ${{inputs.cargo_profiles}} - feat_sets: ${{inputs.feat_sets}} + feat_sets: '["all"]' rust_toolchains: ${{inputs.rust_toolchains}} sys_names: ${{inputs.sys_names}} sys_versions: ${{inputs.sys_versions}} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..4882f174 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,73 @@ +name: Publish + +on: + workflow_call: + inputs: + cargo_profiles: + type: string + default: '["release"]' + description: Cargo profiles + feat_sets: + type: string + description: Cargo feature groups + rust_toolchains: + type: string + description: Rust toolchains + sys_names: + type: string + description: System names + sys_versions: + type: string + description: System versions + rust_targets: + type: string + description: Rust targets + sys_targets: + type: string + description: System targets + machines: + type: string + description: Hardware platform vector + excludes: + type: string + default: '[]' + description: Matrix exclusions + includes: + type: string + default: '[]' + description: Matrix inclusions + +jobs: + dockerhub: + if: ${{ !failure() && !cancelled() && github.ref == 'refs/heads/main' }} + name: DockerHub + uses: ./.github/workflows/bake.yml + with: + bake_targets: '["dockerhub"]' + cargo_profiles: ${{inputs.cargo_profiles}} + feat_sets: ${{inputs.feat_sets}} + rust_toolchains: ${{inputs.rust_toolchains}} + sys_names: ${{inputs.sys_names}} + sys_versions: ${{inputs.sys_versions}} + rust_targets: ${{inputs.rust_targets}} + sys_targets: ${{inputs.sys_targets}} + machines: ${{inputs.machines}} + excludes: ${{inputs.excludes}} + includes: ${{inputs.includes}} + + ghcr: + if: ${{ !failure() && !cancelled() && github.ref == 'refs/heads/main' }} + name: GitHub Container Registry + uses: ./.github/workflows/bake.yml + with: + bake_targets: '["github"]' + cargo_profiles: ${{inputs.cargo_profiles}} + feat_sets: ${{inputs.feat_sets}} + rust_toolchains: ${{inputs.rust_toolchains}} + sys_names: ${{inputs.sys_names}} + sys_versions: ${{inputs.sys_versions}} + rust_targets: ${{inputs.rust_targets}} + sys_targets: ${{inputs.sys_targets}} + machines: ${{inputs.machines}} + excludes: ${{inputs.excludes}} + includes: ${{inputs.includes}} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b0ac22f5..ad73b7a8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -70,7 +70,7 @@ jobs: rust_targets: ${{inputs.rust_targets}} sys_targets: ${{inputs.sys_targets}} machines: ${{inputs.machines}} - excludes: '[{"cargo_profile": "release", "rust_toolchain": "nightly"}, {"feat_set": "default"}]' + excludes: '[{"cargo_profile": "release", "rust_toolchain": "nightly"}, {"cargo_profile": "test", "feat_set": "default"}]' includes: ${{inputs.includes}} complement_tester: diff --git a/docker/Dockerfile.cargo.rpm b/docker/Dockerfile.cargo.rpm new file mode 100644 index 00000000..2063e763 --- /dev/null +++ b/docker/Dockerfile.cargo.rpm @@ -0,0 +1,52 @@ +# syntax = docker/dockerfile:1.11-labs + +FROM input AS rpmbuild +ARG sys_target +ARG rust_toolchain +ARG RUSTUP_HOME +ARG CARGO_HOME +ARG CARGO_TARGET +ARG CARGO_TARGET_DIR +ARG cargo_profile +ARG cargo_features +ARG cargo_spec_features +ARG pkg_dir +ARG gen_rpm_args="" + +WORKDIR /usr/src/tuwunel +RUN \ +--mount=type=cache,dst=${RUSTUP_HOME},sharing=locked \ +--mount=type=cache,dst=${CARGO_HOME},sharing=locked \ +--mount=type=cache,dst=${CARGO_TARGET_DIR},sharing=locked \ +<