Files
tuwunel/.github/workflows/main.yml
2025-06-01 21:13:26 +00:00

186 lines
6.2 KiB
YAML

name: Main
on:
push:
branches:
- "**"
pull_request:
branches:
- "**"
workflow_dispatch:
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true
jobs:
init:
name: Init
runs-on: self-hosted
env:
default_cargo_profiles: '["test", "release"]'
default_feat_sets: '["none", "default", "all"]'
default_rust_toolchains: '["nightly", "stable"]'
default_sys_names: '["debian"]'
default_sys_versions: '["testing-slim"]'
default_rust_targets: '["x86_64-unknown-linux-gnu"]'
default_sys_targets: '["x86_64-linux-gnu"]'
default_machines: '["x86_64"]'
default_excludes: >
[
{"cargo_profile": "release-debuginfo", "rust_toolchain": "nightly"},
{"cargo_profile": "release-max-perf", "rust_toolchain": "stable"},
{"cargo_profile": "release-max-perf", "feat_set": "none"}
]
outputs:
cargo_profiles: ${{vars.CARGO_PROFILES || env.default_cargo_profiles}}
feat_sets: ${{vars.FEAT_SETS || env.default_feat_sets}}
rust_toolchains: ${{vars.RUST_TOOLCHAINS || env.default_rust_toolchains}}
rust_targets: ${{vars.RUST_TARGETS || env.default_rust_targets}}
sys_names: ${{vars.SYS_NAMES || env.default_sys_names}}
sys_targets: ${{vars.SYS_TARGETS || env.default_sys_targets}}
sys_versions: ${{vars.SYS_VERSIONS || env.default_sys_versions}}
machines: ${{vars.MACHINES || env.default_machines}}
excludes: ${{vars.EXCLUDES || env.default_excludes}}
steps:
- name: Initialize Builder
run: |
set +e
docker buildx inspect "${GITHUB_ACTOR}"
if test x"$?" = x"0"; then
exit 0
fi
set -e
cat <<EOF > ./buildkitd.toml
[system]
platformsCacheMaxAge = "504h"
[worker.oci]
enabled = true
rootless = true
gc = false
EOF
docker buildx create \
--bootstrap \
--driver docker-container \
--buildkitd-config ./buildkitd.toml \
--name "${GITHUB_ACTOR}" \
--buildkitd-flags "--allow-insecure-entitlement network.host"
## commented due to https://github.com/orgs/community/discussions/18001
#deps:
# if: ${{fromJSON(vars.CI_VERBOSE_DEPS || 'false')}}
# name: Deps
# needs: [init]
# uses: ./.github/workflows/deps.yml
# with:
# cargo_profiles: ${{needs.init.outputs.cargo_profiles}}
# feat_sets: ${{needs.init.outputs.feat_sets}}
# rust_toolchains: ${{needs.init.outputs.rust_toolchains}}
# rust_targets: ${{needs.init.outputs.rust_targets}}
# sys_names: ${{needs.init.outputs.sys_names}}
# sys_targets: ${{needs.init.outputs.sys_targets}}
# sys_versions: ${{needs.init.outputs.sys_versions}}
# machines: ${{needs.init.outputs.machines}}
# excludes: >
# [
# {"cargo_profile": "release-debuginfo", "rust_toolchain": "nightly"},
# {"cargo_profile": "release-max-perf", "rust_toolchain": "stable"},
# {"cargo_profile": "release-max-perf", "feat_set": "none"}
# ]
lint:
if: >
!failure() && !cancelled()
name: Lint
needs: [init] #needs: [init, deps]
uses: ./.github/workflows/lint.yml
with:
cargo_profiles: ${{needs.init.outputs.cargo_profiles}}
feat_sets: ${{needs.init.outputs.feat_sets}}
rust_toolchains: ${{needs.init.outputs.rust_toolchains}}
rust_targets: ${{needs.init.outputs.rust_targets}}
sys_names: ${{needs.init.outputs.sys_names}}
sys_targets: ${{needs.init.outputs.sys_targets}}
sys_versions: ${{needs.init.outputs.sys_versions}}
machines: ${{needs.init.outputs.machines}}
excludes: ${{needs.init.outputs.excludes}}
test:
if: >
!failure() && !cancelled()
name: Test
needs: [init, lint]
uses: ./.github/workflows/test.yml
with:
cargo_profiles: ${{needs.init.outputs.cargo_profiles}}
feat_sets: ${{needs.init.outputs.feat_sets}}
rust_toolchains: ${{needs.init.outputs.rust_toolchains}}
rust_targets: ${{needs.init.outputs.rust_targets}}
sys_names: ${{needs.init.outputs.sys_names}}
sys_targets: ${{needs.init.outputs.sys_targets}}
sys_versions: ${{needs.init.outputs.sys_versions}}
machines: ${{needs.init.outputs.machines}}
excludes: ${{needs.init.outputs.excludes}}
complement: ${{fromJSON(vars.COMPLEMENT || 'true')}}
package:
if: >
!failure() && !cancelled()
name: Package
needs: [init, lint]
uses: ./.github/workflows/package.yml
with:
cargo_profiles: ${{needs.init.outputs.cargo_profiles}}
feat_sets: ${{needs.init.outputs.feat_sets}}
rust_toolchains: ${{needs.init.outputs.rust_toolchains}}
rust_targets: ${{needs.init.outputs.rust_targets}}
sys_names: ${{needs.init.outputs.sys_names}}
sys_targets: ${{needs.init.outputs.sys_targets}}
sys_versions: ${{needs.init.outputs.sys_versions}}
machines: ${{needs.init.outputs.machines}}
excludes: >
[
{"feat_set": "none"},
{"cargo_profile": "test"},
{"cargo_profile": "release", "rust_toolchain": "nightly"},
{"cargo_profile": "release-max-perf", "feat_set": "default"},
{"cargo_profile": "release-max-perf", "rust_toolchain": "stable"}
]
publish:
if: >
!failure() && !cancelled()
name: Publish
needs: [init, test, package]
uses: ./.github/workflows/publish.yml
with:
docker_repo: ${{vars.DOCKER_REPO}}
cargo_profiles: ${{needs.init.outputs.cargo_profiles}}
feat_sets: ${{needs.init.outputs.feat_sets}}
rust_toolchains: ${{needs.init.outputs.rust_toolchains}}
rust_targets: ${{needs.init.outputs.rust_targets}}
sys_names: ${{needs.init.outputs.sys_names}}
sys_targets: ${{needs.init.outputs.sys_targets}}
sys_versions: ${{needs.init.outputs.sys_versions}}
machines: ${{needs.init.outputs.machines}}
excludes: >
[
{"feat_set": "none"},
{"cargo_profile": "test"},
{"rust_toolchain": "nightly", "cargo_profile": "release"},
{"cargo_profile": "release-max-perf"}
]
secrets:
ghcr_token: ${{ secrets.GHCR_TOKEN }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}