mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-12-06 04:56:33 +08:00
ci(e2e): cache mise on main and provide nextest and k3s to tmachine from the host (#6102)
* fix(tests): provide cargo-nextest to tmachine guests from the host Guests downloaded cargo-nextest from a GitHub release during setup. GitHub's release-asset redirects intermittently fail with HTTP 618 (jwt:expired), and a change to the Ansible tree rebuilds every setup layer at once, so one incident fails many E2E rows together. Fetch the pinned, checksummed release archive with Nix on the host, where it is substituted from the binary cache or downloaded with retries, and unpack it in the guest. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * ci: retry the mise installation The installer downloads mise from a GitHub release, whose asset redirects intermittently fail with HTTP 618 (jwt:expired). Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * refactor(tests): build every tmachine environment setup in one place Base and derived environments now share setupOf, so inputs every setup needs, such as the cargo-nextest archive, are wired once. Base environments with a compute driver now also receive environment_driver. Assert that the guest cargo-nextest pin matches the host's cargo-nextest, so a nixpkgs bump cannot silently skew them. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * ci: simplify the mise installation retry loop Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * chore(tests): drop explanatory comments on the nextest and mise downloads Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * ci: drop the mise installation retry Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * ci(e2e): restore mise, its tools, and kind from a cache saved on main Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * test(tmachine): provide k3s release files from the host Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * refactor(tests): give the tmachine nextest and k3s pins one shape Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> --------- Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
This commit is contained in:
@@ -62,13 +62,21 @@ runs:
|
||||
YAML
|
||||
echo "path=$config" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# kind comes from mise (pinned in mise.lock) rather than a fresh download.
|
||||
- name: Create kind cluster
|
||||
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1.14.0
|
||||
with:
|
||||
cluster_name: ${{ inputs.cluster-name }}
|
||||
shell: bash
|
||||
env:
|
||||
CLUSTER_NAME: ${{ inputs.cluster-name }}
|
||||
# Nodes cannot become Ready until the following CNI installation.
|
||||
wait: ${{ inputs.enforce-network-policy == 'true' && '0s' || '120s' }}
|
||||
config: ${{ steps.kind-config.outputs.path }}
|
||||
WAIT: ${{ inputs.enforce-network-policy == 'true' && '0s' || '120s' }}
|
||||
CONFIG: ${{ steps.kind-config.outputs.path }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
args=(create cluster --name "$CLUSTER_NAME" --wait "$WAIT")
|
||||
if [[ -n "$CONFIG" ]]; then
|
||||
args+=(--config "$CONFIG")
|
||||
fi
|
||||
kind "${args[@]}"
|
||||
|
||||
- name: Install policy-enforcing CNI
|
||||
if: inputs.enforce-network-policy == 'true'
|
||||
|
||||
@@ -17,7 +17,9 @@ runs:
|
||||
id: mise-cache
|
||||
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
|
||||
with:
|
||||
path: ~/.local/share/mise
|
||||
path: |
|
||||
~/.local/bin/mise
|
||||
~/.local/share/mise
|
||||
key: mise-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}-${{ hashFiles('mise.toml', 'mise.lock') }}
|
||||
restore-keys: |
|
||||
mise-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}-
|
||||
@@ -28,7 +30,7 @@ runs:
|
||||
MISE_VERSION: ${{ inputs.version }}
|
||||
run: | # zizmor: ignore[github-env] PATH entries are fixed beneath the runner-controlled HOME
|
||||
set -euo pipefail
|
||||
curl https://mise.run | sh
|
||||
[[ -x "$HOME/.local/bin/mise" ]] || curl -fsSL https://mise.run | sh
|
||||
export PATH="$HOME/.local/bin:$HOME/.local/share/mise/shims:$PATH"
|
||||
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
||||
echo "$HOME/.local/share/mise/shims" >> "$GITHUB_PATH"
|
||||
@@ -38,5 +40,7 @@ runs:
|
||||
if: steps.mise-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
|
||||
with:
|
||||
path: ~/.local/share/mise
|
||||
path: |
|
||||
~/.local/bin/mise
|
||||
~/.local/share/mise
|
||||
key: ${{ steps.mise-cache.outputs.cache-primary-key }}
|
||||
|
||||
@@ -67,6 +67,20 @@ jobs:
|
||||
cargo nextest run --locked --config-file .config/nextest.toml --profile ci --manifest-path examples/supervisor-middleware-content-guard/Cargo.toml --no-run
|
||||
cargo nextest run --locked --config-file .config/nextest.toml --profile ci --manifest-path tests/testkit/Cargo.toml --no-run
|
||||
|
||||
# Restored by the Kubernetes, Podman, and VM E2E jobs through setup-mise, so
|
||||
# PRs that don't change mise.toml or mise.lock don't download the tools from
|
||||
# GitHub.
|
||||
e2e-tools:
|
||||
name: E2E tools cache (Linux X64)
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- uses: ./.github/actions/setup-mise
|
||||
|
||||
# Restored by build-e2e-bundles in branch-e2e.yml.
|
||||
e2e-bundles:
|
||||
name: E2E suite bundles cache (x86_64-unknown-linux-musl)
|
||||
|
||||
@@ -756,7 +756,7 @@ Maintainers should add ready PRs to the queue rather than pressing a direct merg
|
||||
| `.github/workflows/helm-lint.yml` | Helm chart validation. PRs skip lint jobs unless Helm inputs changed; merge groups always validate Helm because they represent the final integration state. |
|
||||
| `.github/actions/setup-nix/action.yml` | Installs Nix and configures the OpenShell Cachix cache, using read-only cache access when no authentication token is available. |
|
||||
| `.github/actions/setup-rust/action.yml` | Restores the Rust target and registry cache. Other branches can restore only their own caches and `main`'s, so per-binary release build caches are saved only on `main`. |
|
||||
| `.github/workflows/rust-cache.yml` | Builds the Branch Checks test targets on each push to `main` to save the `rust-checks` cache that PRs and merge groups restore. Skips the build when the cache already matches. |
|
||||
| `.github/workflows/rust-cache.yml` | Builds the Branch Checks test targets on each push to `main` to save the `rust-checks` cache that PRs and merge groups restore. Skips the build when the cache already matches. Also saves the mise cache that E2E jobs restore, so those jobs download mise and its tools from GitHub only when a PR changes them. |
|
||||
| `.github/workflows/required-ci-gates.yml` | Posts required PR-head and merge-group statuses for gated CI workflows, including for fork PRs. This is what branch protection and merge queue should require. |
|
||||
| `.github/workflows/review-readiness.yml` | Labels newly opened accepted-work PRs using the shared read-only acceptance library, including drafts; routes matching reviewers when a PR is ready and classified. |
|
||||
| `.github/workflows/workflow-security.yml` | Runs informational Actionlint and High-severity Zizmor reports on GitHub-hosted runners. |
|
||||
|
||||
@@ -380,6 +380,38 @@ checksum = "sha256:655d2aadcb1f0a0dd196c5cbc564687ba945a9547c8e82c9fc532051fb260
|
||||
url = "https://github.com/k3d-io/k3d/releases/download/v5.8.3/k3d-windows-amd64.exe"
|
||||
url_api = "https://api.github.com/repos/k3d-io/k3d/releases/assets/229450011"
|
||||
|
||||
[[tools.kind]]
|
||||
version = "0.31.0"
|
||||
backend = "aqua:kubernetes-sigs/kind"
|
||||
|
||||
[tools.kind.options]
|
||||
"vars.version_prefix" = "v"
|
||||
|
||||
[tools.kind."platforms.linux-arm64"]
|
||||
checksum = "sha256:8e1014e87c34901cc422a1445866835d1e666f2a61301c27e722bdeab5a1f7e4"
|
||||
url = "https://github.com/kubernetes-sigs/kind/releases/download/v0.31.0/kind-linux-arm64"
|
||||
url_api = "https://api.github.com/repos/kubernetes-sigs/kind/releases/assets/330009872"
|
||||
|
||||
[tools.kind."platforms.linux-x64"]
|
||||
checksum = "sha256:eb244cbafcc157dff60cf68693c14c9a75c4e6e6fedaf9cd71c58117cb93e3fa"
|
||||
url = "https://github.com/kubernetes-sigs/kind/releases/download/v0.31.0/kind-linux-amd64"
|
||||
url_api = "https://api.github.com/repos/kubernetes-sigs/kind/releases/assets/330009836"
|
||||
|
||||
[tools.kind."platforms.macos-arm64"]
|
||||
checksum = "sha256:88bf554fe9da6311c9f8c2d082613c002911a476f6b5090e9420b35d84e70c5c"
|
||||
url = "https://github.com/kubernetes-sigs/kind/releases/download/v0.31.0/kind-darwin-arm64"
|
||||
url_api = "https://api.github.com/repos/kubernetes-sigs/kind/releases/assets/330009824"
|
||||
|
||||
[tools.kind."platforms.windows-arm64"]
|
||||
checksum = "sha256:2c3a9ff954de16244380778683cf99e271bfc2fac9c6c4e797e4623c45e59d9d"
|
||||
url = "https://github.com/kubernetes-sigs/kind/releases/download/v0.31.0/kind-windows-amd64"
|
||||
url_api = "https://api.github.com/repos/kubernetes-sigs/kind/releases/assets/330009913"
|
||||
|
||||
[tools.kind."platforms.windows-x64"]
|
||||
checksum = "sha256:2c3a9ff954de16244380778683cf99e271bfc2fac9c6c4e797e4623c45e59d9d"
|
||||
url = "https://github.com/kubernetes-sigs/kind/releases/download/v0.31.0/kind-windows-amd64"
|
||||
url_api = "https://api.github.com/repos/kubernetes-sigs/kind/releases/assets/330009913"
|
||||
|
||||
[[tools.kubectl]]
|
||||
version = "1.36.1"
|
||||
backend = "aqua:kubernetes/kubernetes/kubectl"
|
||||
|
||||
@@ -30,6 +30,8 @@ helm = { version = "4.2.0", version_prefix = "v" }
|
||||
helm-docs = "1.14.2"
|
||||
yq = "4.53.6"
|
||||
skaffold = { version = "2.20.0", os = ["linux", "macos"], version_prefix = "v" }
|
||||
# Creates the Kubernetes E2E cluster in CI (.github/actions/setup-e2e-kind).
|
||||
kind = { version = "0.31.0", os = ["linux", "macos"], version_prefix = "v" }
|
||||
# Keep k3d out of Linux CI images until upstream ships a release rebuilt with
|
||||
# patched Go/container dependencies. Linux Kubernetes E2E uses kind or an
|
||||
# externally provided cluster context.
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
gather_facts: false
|
||||
vars:
|
||||
helm_version: 4.2.0
|
||||
k3s_version: 1.33.13+k3s2
|
||||
tasks:
|
||||
- name: Wait for SSH
|
||||
ansible.builtin.wait_for_connection:
|
||||
@@ -21,12 +20,18 @@
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
# get.k3s.io serves the latest script, so pin the one from the k3s_version
|
||||
# release tag. Update the checksum whenever k3s_version changes.
|
||||
- name: Download K3s installer
|
||||
ansible.builtin.get_url:
|
||||
url: "https://raw.githubusercontent.com/k3s-io/k3s/v{{ k3s_version | urlencode }}/install.sh"
|
||||
checksum: sha256:9ca7930c31179d83bc13de20078fd8ad3e1ee00875b31f39a7e524ca4ef7d9de
|
||||
# The host provides the K3s binary and the install script from the same
|
||||
# release (`k3s_binary` and `k3s_installer`, pinned and checksummed in
|
||||
# tests/tmachine/config.nix), so the script doesn't download anything.
|
||||
- name: Copy K3s binary
|
||||
ansible.builtin.copy:
|
||||
src: "{{ k3s_binary }}"
|
||||
dest: /usr/local/bin/k3s
|
||||
mode: "0755"
|
||||
|
||||
- name: Copy K3s installer
|
||||
ansible.builtin.copy:
|
||||
src: "{{ k3s_installer }}"
|
||||
dest: /tmp/install-k3s.sh
|
||||
mode: "0755"
|
||||
|
||||
@@ -37,9 +42,9 @@
|
||||
- server
|
||||
- --disable=servicelb
|
||||
- --disable=traefik
|
||||
creates: /usr/local/bin/k3s
|
||||
creates: /etc/systemd/system/k3s.service
|
||||
environment:
|
||||
INSTALL_K3S_VERSION: "v{{ k3s_version }}"
|
||||
INSTALL_K3S_SKIP_DOWNLOAD: "true"
|
||||
|
||||
- name: Wait for K3s
|
||||
ansible.builtin.command:
|
||||
|
||||
@@ -6,45 +6,14 @@
|
||||
hosts: all
|
||||
become: true
|
||||
gather_facts: false
|
||||
vars:
|
||||
nextest_version: 0.9.143
|
||||
nextest_arches:
|
||||
x86_64:
|
||||
triple: x86_64-unknown-linux-musl
|
||||
sha256: 6d891c18105ec2d33f6e441a4f92b7ccab47ba263e22055c8bb66884243f3389
|
||||
aarch64:
|
||||
triple: aarch64-unknown-linux-musl
|
||||
sha256: 0560ce0ce017f368c54b5db86588370fc03b470985490fa81200e62a657dda05
|
||||
tasks:
|
||||
- name: Wait for SSH
|
||||
ansible.builtin.wait_for_connection:
|
||||
|
||||
- name: Gather guest architecture
|
||||
ansible.builtin.setup:
|
||||
filter:
|
||||
- ansible_architecture
|
||||
|
||||
- name: Select cargo-nextest release for guest architecture
|
||||
ansible.builtin.set_fact:
|
||||
nextest_release: "{{ nextest_arches[ansible_facts.architecture] | default({}) }}"
|
||||
|
||||
- name: Validate guest architecture
|
||||
ansible.builtin.assert:
|
||||
that: nextest_release | length > 0
|
||||
fail_msg: "cargo-nextest is unsupported on {{ ansible_facts.architecture }}"
|
||||
|
||||
- name: Download cargo-nextest
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/nextest-rs/nextest/releases/download/cargo-nextest-{{ nextest_version }}/cargo-nextest-{{ nextest_version }}-{{ nextest_release.triple }}.tar.gz"
|
||||
dest: /tmp/cargo-nextest.tar.gz
|
||||
checksum: "sha256:{{ nextest_release.sha256 }}"
|
||||
mode: "0600"
|
||||
|
||||
- name: Install cargo-nextest
|
||||
ansible.builtin.unarchive:
|
||||
src: /tmp/cargo-nextest.tar.gz
|
||||
src: "{{ cargo_nextest_archive }}"
|
||||
dest: /usr/local/bin
|
||||
remote_src: true
|
||||
creates: /usr/local/bin/cargo-nextest
|
||||
|
||||
- name: Verify cargo-nextest
|
||||
|
||||
+70
-14
@@ -23,6 +23,71 @@ let
|
||||
OVMF = firmwarePkgs.OVMF;
|
||||
};
|
||||
qemu = qemuPkgs.qemu.override { hostCpuOnly = true; };
|
||||
nextestVersion =
|
||||
let
|
||||
version = "0.9.143";
|
||||
in
|
||||
assert pkgs.lib.assertMsg (
|
||||
pkgs.cargo-nextest.version == version
|
||||
) "the guest cargo-nextest (${version}) must match the host's (${pkgs.cargo-nextest.version})";
|
||||
version;
|
||||
# Release assets for the guest, whose architecture matches the host's.
|
||||
guestArch = if isAarch64 then "aarch64" else "x86_64";
|
||||
nextestAsset =
|
||||
{
|
||||
aarch64 = {
|
||||
name = "cargo-nextest-${nextestVersion}-aarch64-unknown-linux-musl.tar.gz";
|
||||
sha256 = "0560ce0ce017f368c54b5db86588370fc03b470985490fa81200e62a657dda05";
|
||||
};
|
||||
x86_64 = {
|
||||
name = "cargo-nextest-${nextestVersion}-x86_64-unknown-linux-musl.tar.gz";
|
||||
sha256 = "6d891c18105ec2d33f6e441a4f92b7ccab47ba263e22055c8bb66884243f3389";
|
||||
};
|
||||
}
|
||||
.${guestArch};
|
||||
setupInputs = {
|
||||
cargo_nextest_archive = "${pkgs.fetchurl {
|
||||
url = "https://github.com/nextest-rs/nextest/releases/download/cargo-nextest-${nextestVersion}/${nextestAsset.name}";
|
||||
inherit (nextestAsset) sha256;
|
||||
}}";
|
||||
};
|
||||
k3sVersion = "1.33.13+k3s2";
|
||||
k3sRelease = "https://github.com/k3s-io/k3s/releases/download/v${pkgs.lib.escapeURL k3sVersion}";
|
||||
k3sAsset =
|
||||
{
|
||||
aarch64 = {
|
||||
name = "k3s-arm64";
|
||||
sha256 = "cf6afb3944f9ecf120fa2837b542479018c08f9ea1d1d181d4a68445e7717a8d";
|
||||
};
|
||||
x86_64 = {
|
||||
name = "k3s";
|
||||
sha256 = "1572f0f23bd5a844bd405b71875877aacacc7ab79e279d3d73735654c37c7735";
|
||||
};
|
||||
}
|
||||
.${guestArch};
|
||||
k3sSetupInputs = {
|
||||
k3s_binary = "${pkgs.fetchurl {
|
||||
url = "${k3sRelease}/${k3sAsset.name}";
|
||||
inherit (k3sAsset) sha256;
|
||||
}}";
|
||||
# The install script from the same release tag (get.k3s.io serves the latest).
|
||||
k3s_installer = "${pkgs.fetchurl {
|
||||
url = "https://raw.githubusercontent.com/k3s-io/k3s/v${pkgs.lib.escapeURL k3sVersion}/install.sh";
|
||||
sha256 = "9ca7930c31179d83bc13de20078fd8ad3e1ee00875b31f39a7e524ca4ef7d9de";
|
||||
}}";
|
||||
};
|
||||
# The setup of an environment built on `parent`: its playbooks and inputs,
|
||||
# then `extra`'s. A parent with a compute driver also passes it as
|
||||
# `environment_driver`, for setup that configures the gateway's driver table.
|
||||
setupOf = parent: extra: {
|
||||
inherit (parent) use_galaxy;
|
||||
playbooks = parent.playbooks ++ (extra.playbooks or [ ]);
|
||||
inputs =
|
||||
setupInputs
|
||||
// (parent.inputs or { })
|
||||
// (if parent ? driver then { environment_driver = parent.driver; } else { })
|
||||
// (extra.inputs or { });
|
||||
};
|
||||
# Every installer loads the sandbox workload image tests run python3 in.
|
||||
e2ePythonImage = "../../artifacts/images/openshell-e2e-python-dev.tar";
|
||||
k3sInputs = {
|
||||
@@ -46,7 +111,7 @@ let
|
||||
];
|
||||
};
|
||||
# Base environments, keyed by name: a machine and the playbooks that set up
|
||||
# its container engine (or k3s).
|
||||
# its container engine (or k3s), with the inputs they read.
|
||||
bases = {
|
||||
ubuntu-docker-rootful = {
|
||||
machine = "ubuntu";
|
||||
@@ -68,6 +133,7 @@ let
|
||||
"ansible/playbooks/test-tools.yaml"
|
||||
"ansible/playbooks/k3s.yaml"
|
||||
];
|
||||
inputs = k3sSetupInputs;
|
||||
};
|
||||
fedora-podman-rootful = fedoraPodman "rootful";
|
||||
fedora-podman-rootless = fedoraPodman "rootless";
|
||||
@@ -78,9 +144,7 @@ let
|
||||
"fedora-podman-rootless"
|
||||
];
|
||||
# An environment named <base>-<suffix>: a base with more setup playbooks and
|
||||
# the inputs they read, run after the base's own. A base with a compute driver
|
||||
# also passes it as `environment_driver`, for setup that configures the
|
||||
# gateway's driver table.
|
||||
# the inputs they read, run after the base's own.
|
||||
withSetup =
|
||||
base: suffix: setup:
|
||||
let
|
||||
@@ -89,13 +153,7 @@ let
|
||||
{
|
||||
name = "${base}-${suffix}";
|
||||
inherit (parent) machine;
|
||||
setup = {
|
||||
inherit (parent) use_galaxy;
|
||||
playbooks = parent.playbooks ++ setup.playbooks;
|
||||
inputs =
|
||||
(if parent ? driver then { environment_driver = parent.driver; } else { })
|
||||
// (setup.inputs or { });
|
||||
};
|
||||
setup = setupOf parent setup;
|
||||
};
|
||||
# Feature environments, <base>-<feature>, one per base the feature supports.
|
||||
# A suite that needs a feature's setup runs in that environment, so the setup
|
||||
@@ -175,9 +233,7 @@ let
|
||||
pkgs.lib.mapAttrsToList (name: base: {
|
||||
inherit name;
|
||||
inherit (base) machine;
|
||||
setup = {
|
||||
inherit (base) use_galaxy playbooks;
|
||||
};
|
||||
setup = setupOf base { };
|
||||
}) bases
|
||||
++ featureEnvironments
|
||||
++ podmanUsernsEnvironments;
|
||||
|
||||
Reference in New Issue
Block a user