Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 95 additions & 14 deletions .github/workflows/provider-ghcr-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: provider-ghcr-e2e

on:
pull_request:
push:
branches:
- main
Expand All @@ -12,7 +13,32 @@ permissions:

jobs:
push-install-run:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- provider: echo-provider
alias: echo
provider_ref: sourceplane/echo-provider
release_repo: kiox-echo-provider
main_package: ./cmd/echo-provider
- provider: multi-tool-provider
alias: echo
provider_ref: acme/multi-tool-provider
release_repo: kiox-multi-tool-provider
main_package: ""
- provider: inline-tool-provider
alias: inline
provider_ref: acme/inline-tool-provider
release_repo: kiox-inline-tool-provider
main_package: ""
- provider: setup-kubectl
alias: setup-kubectl
provider_ref: acme/setup-kubectl
release_repo: kiox-setup-kubectl
main_package: ""
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -31,7 +57,7 @@ jobs:
id: vars
run: |
owner=$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')
echo "ref=ghcr.io/${owner}/kiox-echo-provider:ci-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" >> "$GITHUB_OUTPUT"
echo "ref=ghcr.io/${owner}/${{ matrix.release_repo }}:ci-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" >> "$GITHUB_OUTPUT"

- name: Login to GHCR
uses: docker/login-action@v3
Expand All @@ -40,26 +66,81 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Package and push example provider
- name: Package and push provider
working-directory: testdata/${{ matrix.provider }}
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./bin/kiox release \
--manifest testdata/echo-provider/kiox.yaml \
--main ./cmd/echo-provider \
--dist testdata/echo-provider/dist \
--output testdata/echo-provider/oci \
--push "${{ steps.vars.outputs.ref }}"
args=(release --dist dist --output oci --push "${{ steps.vars.outputs.ref }}")
if [ -n "${{ matrix.main_package }}" ]; then
args+=(--main "${{ matrix.main_package }}")
fi
../../bin/kiox "${args[@]}"

- name: Install provider from GHCR
working-directory: testdata/${{ matrix.provider }}
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
home="$RUNNER_TEMP/kiox-home-${{ matrix.provider }}"
../../bin/kiox --kiox-home "$home" install "${{ steps.vars.outputs.ref }}"
../../bin/kiox --kiox-home "$home" provider list default | tee "$RUNNER_TEMP/${{ matrix.provider }}-install.out"
grep -q "${{ matrix.provider_ref }}" "$RUNNER_TEMP/${{ matrix.provider }}-install.out"

- name: Create workspace and run from GHCR
working-directory: testdata/${{ matrix.provider }}
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd testdata/echo-provider
workspace_root="$RUNNER_TEMP/kiox-workspace"
../../bin/kiox --kiox-home "$RUNNER_TEMP/kiox-home" init "$workspace_root"
../../bin/kiox --kiox-home "$RUNNER_TEMP/kiox-home" --workspace "$workspace_root" add "${{ steps.vars.outputs.ref }}" as echo
../../bin/kiox --kiox-home "$RUNNER_TEMP/kiox-home" --workspace "$workspace_root" -- echo plan --intent "$PWD/intent.yaml" | tee "$RUNNER_TEMP/echo-run.out"
grep -q "capability=plan" "$RUNNER_TEMP/echo-run.out"
workspace_root="$RUNNER_TEMP/${{ matrix.provider }}-workspace"
home="$RUNNER_TEMP/kiox-home-${{ matrix.provider }}"
../../bin/kiox --kiox-home "$home" init "$workspace_root"
../../bin/kiox --kiox-home "$home" --workspace "$workspace_root" add "${{ steps.vars.outputs.ref }}" as "${{ matrix.alias }}"

case "${{ matrix.provider }}" in
echo-provider)
../../bin/kiox --kiox-home "$home" --workspace "$workspace_root" -- echo plan --intent "$PWD/intent.yaml" | tee "$RUNNER_TEMP/echo-run.out"
grep -q 'capability=plan' "$RUNNER_TEMP/echo-run.out"
;;
multi-tool-provider)
../../bin/kiox --kiox-home "$home" --workspace "$workspace_root" -- echo one two | tee "$RUNNER_TEMP/multi-run.out"
../../bin/kiox --kiox-home "$home" --workspace "$workspace_root" -- echo-tool alpha beta | tee "$RUNNER_TEMP/multi-tool-run.out"
grep -q 'normalized-env=hello-normalized' "$RUNNER_TEMP/multi-run.out"
grep -q 'normalized-args=one two' "$RUNNER_TEMP/multi-run.out"
grep -q 'normalized-args=alpha beta' "$RUNNER_TEMP/multi-tool-run.out"
;;
inline-tool-provider)
../../bin/kiox --kiox-home "$home" --workspace "$workspace_root" -- inline red blue | tee "$RUNNER_TEMP/inline-run.out"
../../bin/kiox --kiox-home "$home" --workspace "$workspace_root" -- inline-tool green gold | tee "$RUNNER_TEMP/inline-tool-run.out"
grep -q 'inline-env=hello-inline' "$RUNNER_TEMP/inline-run.out"
grep -q 'inline-mode=inline' "$RUNNER_TEMP/inline-run.out"
grep -q 'inline-asset=hello-from-inline-assets' "$RUNNER_TEMP/inline-run.out"
grep -q 'inline-args=red blue' "$RUNNER_TEMP/inline-run.out"
grep -q 'inline-args=green gold' "$RUNNER_TEMP/inline-tool-run.out"
;;
setup-kubectl)
server_root="$RUNNER_TEMP/kubectl-release"
mkdir -p "$server_root/v1.29.15/bin/linux/amd64"
printf 'v1.29.15\n' > "$server_root/stable.txt"
printf 'v1.29.15\n' > "$server_root/stable-1.29.txt"
printf '%s\n' \
'#!/bin/sh' \
'set -eu' \
"printf 'kubectl-version=%s\\n' 'v1.29.15'" \
"printf 'kubectl-args=%s\\n' \"\$*\"" \
> "$server_root/v1.29.15/bin/linux/amd64/kubectl"
chmod +x "$server_root/v1.29.15/bin/linux/amd64/kubectl"
python3 -m http.server 18080 --bind 127.0.0.1 --directory "$server_root" >/tmp/kubectl-server.log 2>&1 &
server_pid=$!
trap 'kill "$server_pid"' EXIT
curl -fsS --retry 10 --retry-connrefused --retry-delay 1 \
"http://127.0.0.1:18080/stable-1.29.txt" >/dev/null
KUBECTL_RELEASE_BASE_URL="http://127.0.0.1:18080" KUBECTL_VERSION="1.29" \
../../bin/kiox --kiox-home "$home" --workspace "$workspace_root" -- kubectl version --client | tee "$RUNNER_TEMP/kubectl-run.out"
grep -q 'kubectl-version=v1.29.15' "$RUNNER_TEMP/kubectl-run.out"
grep -q 'kubectl-args=version --client' "$RUNNER_TEMP/kubectl-run.out"
;;
esac
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test-core:

release-example: build
./$(KIOX_BIN) release \
--manifest $(ECHO_PROVIDER_DIR)/kiox.yaml \
--manifest $(ECHO_PROVIDER_DIR)/provider.yaml \
--main ./cmd/echo-provider \
--dist $(ECHO_PROVIDER_DIST) \
--output $(ECHO_PROVIDER_OCI)
Expand All @@ -61,7 +61,7 @@ e2e-local: run-example

ghcr-push: build
./$(KIOX_BIN) release \
--manifest $(ECHO_PROVIDER_DIR)/kiox.yaml \
--manifest $(ECHO_PROVIDER_DIR)/provider.yaml \
--main ./cmd/echo-provider \
--dist $(ECHO_PROVIDER_DIST) \
--output $(ECHO_PROVIDER_OCI) \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Build kiox and package the normalized multi-tool fixture:
```bash
make build
./bin/kiox release \
--manifest testdata/multi-tool-provider/kiox.yaml \
--manifest testdata/multi-tool-provider/provider.yaml \
--dist testdata/multi-tool-provider/dist \
--output testdata/multi-tool-provider/oci
```
Expand Down
8 changes: 4 additions & 4 deletions TEST_PROVIDERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ make build

```bash
./bin/kiox release \
--manifest testdata/echo-provider/kiox.yaml \
--manifest testdata/echo-provider/provider.yaml \
--dist testdata/echo-provider/dist \
--output testdata/echo-provider/oci

Expand All @@ -26,7 +26,7 @@ make build

```bash
./bin/kiox release \
--manifest testdata/multi-tool-provider/kiox.yaml \
--manifest testdata/multi-tool-provider/provider.yaml \
--dist testdata/multi-tool-provider/dist \
--output testdata/multi-tool-provider/oci

Expand All @@ -40,7 +40,7 @@ make build

```bash
./bin/kiox release \
--manifest testdata/inline-tool-provider/kiox.yaml \
--manifest testdata/inline-tool-provider/provider.yaml \
--dist testdata/inline-tool-provider/dist \
--output testdata/inline-tool-provider/oci

Expand All @@ -54,7 +54,7 @@ make build

```bash
./bin/kiox release \
--manifest testdata/setup-kubectl/kiox.yaml \
--manifest testdata/setup-kubectl/provider.yaml \
--dist testdata/setup-kubectl/dist \
--output testdata/setup-kubectl/oci

Expand Down
2 changes: 1 addition & 1 deletion internal/build/goreleaser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestResolveGoReleaserConfigPrefersExplicitPath(t *testing.T) {

func TestResolveGoReleaserConfigGeneratesFromManifest(t *testing.T) {
moduleRoot := t.TempDir()
manifestPath := filepath.Join(moduleRoot, "kiox.yaml")
manifestPath := filepath.Join(moduleRoot, "provider.yaml")
content := `apiVersion: kiox.io/v1
kind: Provider
metadata:
Expand Down
12 changes: 6 additions & 6 deletions internal/cmd/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestReleaseAndInstallLocalLayout(t *testing.T) {
releaseBuf := runRootCommand(t, []string{
"--kiox-home", home,
"release",
"--manifest", filepath.Join(providerDir, "kiox.yaml"),
"--manifest", providerManifestPath(providerDir),
"--dist", filepath.Join(providerDir, "dist"),
"--output", filepath.Join(providerDir, "oci"),
})
Expand All @@ -46,7 +46,7 @@ func TestReleaseAndInstallLocalLayout(t *testing.T) {
for _, expected := range []string{
filepath.Join(home, "providers", "sourceplane", "echo-provider", "v0.1.0", "metadata.json"),
filepath.Join(meta.StorePath, "oci", "index.json"),
filepath.Join(meta.StorePath, "kiox.yaml"),
filepath.Join(meta.StorePath, preferredProviderManifestName),
} {
if _, err := os.Stat(expected); err != nil {
t.Fatalf("expected installed artifact %s: %v", expected, err)
Expand Down Expand Up @@ -81,7 +81,7 @@ cp dist/bin/darwin/amd64/echo-provider dist/bin/linux/arm64/echo-provider
releaseBuf := runRootCommand(t, []string{
"--kiox-home", home,
"release",
"--manifest", filepath.Join(providerDir, "kiox.yaml"),
"--manifest", providerManifestPath(providerDir),
"--dist", filepath.Join(providerDir, "artifacts"),
"--output", filepath.Join(providerDir, "oci"),
"--delegate-goreleaser",
Expand Down Expand Up @@ -147,7 +147,7 @@ cp dist/bin/darwin/amd64/echo-provider dist/bin/linux/arm64/echo-provider
releaseBuf := runRootCommand(t, []string{
"--kiox-home", home,
"release",
"--manifest", filepath.Join(providerDir, "kiox.yaml"),
"--manifest", providerManifestPath(providerDir),
"--dist", filepath.Join(providerDir, "artifacts"),
"--output", filepath.Join(providerDir, "oci"),
"--delegate-goreleaser",
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestReleasePushAndInstallFromRegistry(t *testing.T) {
releaseBuf := runRootCommand(t, []string{
"--kiox-home", home,
"release",
"--manifest", filepath.Join(providerDir, "kiox.yaml"),
"--manifest", providerManifestPath(providerDir),
"--dist", filepath.Join(providerDir, "dist"),
"--output", filepath.Join(providerDir, "oci"),
"--push", ref,
Expand Down Expand Up @@ -222,7 +222,7 @@ func TestInstallUsesCachedRemoteProvider(t *testing.T) {
releaseBuf := runRootCommand(t, []string{
"--kiox-home", home,
"release",
"--manifest", filepath.Join(providerDir, "kiox.yaml"),
"--manifest", providerManifestPath(providerDir),
"--dist", filepath.Join(providerDir, "dist"),
"--output", filepath.Join(providerDir, "oci"),
"--push", ref,
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func releaseStandaloneProviderLayout(t *testing.T, home, providerDir string) str
buf := runRootCommand(t, []string{
"--kiox-home", home,
"release",
"--manifest", filepath.Join(providerDir, "kiox.yaml"),
"--manifest", providerManifestPath(providerDir),
"--dist", filepath.Join(providerDir, "dist"),
"--output", layoutPath,
})
Expand Down
14 changes: 9 additions & 5 deletions internal/cmd/workspace_cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func TestDashShortcutReusesCachedTaggedRegistryProvider(t *testing.T) {
if err != nil {
t.Fatalf("load workspace provider metadata: %v", err)
}
for _, path := range []string{filepath.Join(meta.StorePath, "package.json"), filepath.Join(meta.StorePath, "kiox.yaml")} {
for _, path := range []string{filepath.Join(meta.StorePath, "package.json"), filepath.Join(meta.StorePath, preferredProviderManifestName)} {
if err := os.Remove(path); err != nil {
t.Fatalf("remove cached package file %s: %v", path, err)
}
Expand Down Expand Up @@ -1245,7 +1245,7 @@ func createCapabilityProviderProject(t *testing.T, dir, namespace, name, capabil
" description: test capability",
"",
}, "\n")
if err := os.WriteFile(filepath.Join(dir, "kiox.yaml"), []byte(manifest), 0o644); err != nil {
if err := os.WriteFile(providerManifestPath(dir), []byte(manifest), 0o644); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(dir, "cmd", name, "main.go"), []byte(mainSource), 0o644); err != nil {
Expand All @@ -1254,13 +1254,17 @@ func createCapabilityProviderProject(t *testing.T, dir, namespace, name, capabil
return dir
}

func providerManifestPath(providerDir string) string {
return filepath.Join(providerDir, preferredProviderManifestName)
}

func releaseProviderLayout(t *testing.T, home, providerDir string) string {
t.Helper()
layoutPath := filepath.Join(providerDir, "oci")
buf := runRootCommand(t, []string{
"--kiox-home", home,
"release",
"--manifest", filepath.Join(providerDir, "kiox.yaml"),
"--manifest", providerManifestPath(providerDir),
"--dist", filepath.Join(providerDir, "dist"),
"--output", layoutPath,
})
Expand All @@ -1272,7 +1276,7 @@ func releaseProviderLayout(t *testing.T, home, providerDir string) string {

func setProviderVersion(t *testing.T, providerDir, version string) {
t.Helper()
manifestPath := filepath.Join(providerDir, "kiox.yaml")
manifestPath := providerManifestPath(providerDir)
data, err := os.ReadFile(manifestPath)
if err != nil {
t.Fatal(err)
Expand All @@ -1291,7 +1295,7 @@ func releaseProviderRef(t *testing.T, home, providerDir, ref string) {
buf := runRootCommand(t, []string{
"--kiox-home", home,
"release",
"--manifest", filepath.Join(providerDir, "kiox.yaml"),
"--manifest", providerManifestPath(providerDir),
"--dist", filepath.Join(providerDir, "dist"),
"--output", filepath.Join(providerDir, "oci"),
"--push", ref,
Expand Down
4 changes: 2 additions & 2 deletions internal/manifest/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestLoadProvider(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "kiox.yaml")
path := filepath.Join(dir, "provider.yaml")
content := strings.Join([]string{
"apiVersion: kiox.io/v1",
"kind: Provider",
Expand Down Expand Up @@ -56,7 +56,7 @@ func TestLoadProvider(t *testing.T) {

func TestLoadProviderRequiresPlatforms(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "kiox.yaml")
path := filepath.Join(dir, "provider.yaml")
content := `apiVersion: kiox.io/v1
kind: Provider
metadata:
Expand Down
Loading
Loading