Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: run CI tests in parallel, remove alpha status #645

Merged
merged 9 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
9 changes: 7 additions & 2 deletions .github/actions/save-logs/action.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
name: save-logs
description: "Save debug logs"

inputs:
name:
description: "unique name to put in log file"
required: true

runs:
using: composite
steps:
- name: Fix log permissions
run: |
sudo chown $USER /tmp/zarf-*.log || echo ""
sudo chown $USER /tmp/uds-${{ inputs.name }}.log || echo ""
shell: bash

- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: debug-log
path: /tmp/zarf-*.log
path: /tmp/uds-${{ inputs.name }}.log
28 changes: 28 additions & 0 deletions .github/actions/setup-from-previous/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: setup-from-previous
description: grabs artifact from a previous job and sets up the env for tests

runs:
using: composite
steps:
# Checkout the repo and setup the tooling for this job
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: Download build artifacts
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: build-artifacts
path: build/

- name: Setup golang
uses: ./.github/actions/golang

- name: Make UDS-CLI executable
shell: bash
run: |
chmod +x build/uds

- name: Setup K3d
uses: ./.github/actions/k3d
124 changes: 117 additions & 7 deletions .github/workflows/test-e2e-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,138 @@ concurrency:
cancel-in-progress: true

jobs:
test:
build:
runs-on: ubuntu-latest
steps:
# Checkout the repo and setup the tooling for this job
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: Setup golang
uses: ./.github/actions/golang

- name: Install UDS CLI
uses: ./.github/actions/install-uds-cli

- name: Build UDS-CLI binary
run: uds run build-cli-linux-amd
- name: Build CLI
run: |
uds run build-cli-linux-amd

# Upload the contents of the build directory for later stages to use
- name: Upload build artifacts
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: build-artifacts
path: build/
retention-days: 1
test-bundle:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: setup-using-previous-job
uses: ./.github/actions/setup-from-previous

- name: Run e2e bundle tests
run: |
build/uds run test:run-bundle-test --no-progress

- name: Save logs
if: always()
uses: ./.github/actions/save-logs
with:
name: build

test-dev:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: setup-using-previous-job
uses: ./.github/actions/setup-from-previous

- name: Run e2e dev tests
run: |
build/uds run test:run-dev-test --no-progress

- name: Save logs
if: always()
uses: ./.github/actions/save-logs
with:
name: dev-test

test-variables:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: setup-using-previous-job
uses: ./.github/actions/setup-from-previous

- name: Run e2e variable tests
run: |
build/uds run test:run-variable-test --no-progress

- name: Save logs
if: always()
uses: ./.github/actions/save-logs
with:
name: test-variables

test-optional-bundle:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: setup-using-previous-job
uses: ./.github/actions/setup-from-previous

- name: Run e2e optional bundle tests
run: |
build/uds run test:run-optional-bundle-tests --no-progress

- name: Save logs
if: always()
uses: ./.github/actions/save-logs
with:
name: test-optional-bundle

test-vendor:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: Setup K3d
uses: ./.github/actions/k3d
- name: setup-using-previous-job
uses: ./.github/actions/setup-from-previous

- name: Run e2e tests
- name: Run e2e vendor tests
run: |
build/uds run test:e2e-no-ghcr-write --no-progress
build/uds run test:run-vendor-tests --no-progress

- name: Save logs
if: always()
uses: ./.github/actions/save-logs
with:
name: test-vendor
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
[![Build Status](https://img.shields.io/github/actions/workflow/status/defenseunicorns/uds-cli/release.yaml)](https://github.com/defenseunicorns/uds-cli/actions/workflows/release.yaml)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/uds-cli/badge)](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/uds-cli)

**:warning: Warning**: UDS-CLI is in early alpha, expect changes to the schema and workflow

## Table of Contents

1. [Install](#install)
Expand Down
6 changes: 0 additions & 6 deletions src/test/e2e/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ import (
"github.com/defenseunicorns/uds-cli/src/config"
)

func zarfPublish(t *testing.T, path string, reg string) {
args := strings.Split(fmt.Sprintf("zarf package publish %s oci://%s --insecure --oci-concurrency=10 -l debug", path, reg), " ")
_, _, err := e2e.UDS(args...)
require.NoError(t, err)
}

func TestUDSCmd(t *testing.T) {
_, _, err := e2e.UDS()
require.NoError(t, err)
Expand Down
6 changes: 6 additions & 0 deletions src/test/e2e/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ import (

// This file contains helpers for running UDS CLI commands (ie. uds create/deploy/etc with various flags and options)

func zarfPublish(t *testing.T, path string, reg string) {
args := strings.Split(fmt.Sprintf("zarf package publish %s oci://%s --insecure --oci-concurrency=10 -l debug --no-progress", path, reg), " ")
_, _, err := e2e.UDS(args...)
require.NoError(t, err)
}

func createLocal(t *testing.T, bundlePath string, arch string) {
cmd := strings.Split(fmt.Sprintf("create %s --insecure --confirm -a %s", bundlePath, arch), " ")
_, _, err := e2e.UDS(cmd...)
Expand Down
119 changes: 0 additions & 119 deletions src/test/e2e/runner_inputs_test.go

This file was deleted.

32 changes: 28 additions & 4 deletions tasks/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,41 @@ tasks:
- name: e2e-no-ghcr-write
description: run e2e tests without writing to GHCR
actions:
- cmd: cd src/test/e2e && go test -failfast -v -timeout 30m -skip ".*GHCR.*"
- task: run-bundle-test
- task: run-dev-test
- task: run-variable-test
- task: run-optional-bundle-tests
- task: run-vendor-tests

- name: e2e-ghcr
description: run e2e tests that write to GHCR
actions:
- cmd: cd src/test/e2e && go test -failfast -v -timeout 30m -run ".*GHCR.*"

- name: e2e-runner
description: run e2e tests for task runner only
- name: run-bundle-test
description: only run tests in bundle_test.go
actions:
- cmd: cd src/test/e2e && go test -failfast -v -timeout 30m -run TestTaskRunner
- cmd: cd src/test/e2e && go test -failfast -v -timeout 30m bundle_test.go commands_test.go main_test.go

- name: run-dev-test
description: only run tests in dev.go
actions:
- cmd: cd src/test/e2e && go test -failfast -v -timeout 30m dev_test.go commands_test.go main_test.go

- name: run-variable-test
description: only run tests in variable_test.go
actions:
- cmd: cd src/test/e2e && go test -failfast -v -timeout 30m variable_test.go commands_test.go main_test.go

- name: run-optional-bundle-tests
description: only run tests in optional_bundle_test.go
actions:
- cmd: cd src/test/e2e && go test -failfast -v -timeout 30m optional_bundle_test.go commands_test.go main_test.go

- name: run-vendor-tests
description: only run tests in zarf_test.go and runner_test.go
actions:
- cmd: cd src/test/e2e && go test -failfast -v -timeout 30m zarf_test.go runner_test.go commands_test.go main_test.go

- name: push-test-artifacts
description: push artifacts that UDS CLI tests rely on to GHCR
Expand Down
Loading