-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): make e2e test workflow reusable (#365)
Related to #347
- Loading branch information
1 parent
8e1390f
commit d94408c
Showing
16 changed files
with
149 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ jobs: | |
args: --timeout=10m | ||
unit: | ||
name: unit tests | ||
runs-on: ubuntu-22.04 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | ||
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 | ||
|
@@ -48,67 +48,12 @@ jobs: | |
cache: false | ||
- name: Unit Tests with the Go CLI | ||
run: go test ./... -short -race -cover | ||
end-to-end: | ||
|
||
e2e: | ||
name: e2e tests | ||
runs-on: ubuntu-22.04 | ||
env: | ||
BATS_LIB_PATH: /usr/lib | ||
TEST_TERMINAL_WIDTH: 200 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | ||
- name: Check out platform | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | ||
with: | ||
repository: opentdf/platform | ||
path: platform | ||
- name: Set up go | ||
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 | ||
- uses: opentdf/otdfctl/e2e@feat/e2e-ci | ||
with: | ||
go-version-file: 'platform/service/go.mod' | ||
check-latest: false | ||
cache-dependency-path: | | ||
platform/service/go.sum | ||
platform/protocol/go/go.sum | ||
platform/sdk/go.sum | ||
- run: | | ||
.github/scripts/init-temp-keys.sh | ||
cp opentdf-dev.yaml opentdf.yaml | ||
working-directory: platform | ||
- name: Added Trusted Certs | ||
run: | | ||
sudo chmod -R 777 ./keys | ||
sudo apt-get install -y ca-certificates | ||
sudo cp ./keys/localhost.crt /usr/local/share/ca-certificates | ||
sudo update-ca-certificates | ||
working-directory: platform | ||
- run: docker compose up -d --wait --wait-timeout 240 | ||
working-directory: platform | ||
- run: go run ./service provision keycloak | ||
working-directory: platform | ||
- run: go run ./service provision fixtures | ||
working-directory: platform | ||
- uses: JarvusInnovations/background-action@2428e7b970a846423095c79d43f759abf979a635 | ||
name: start server in background | ||
with: | ||
run: > | ||
go build -o opentdf -v service/main.go | ||
&& .github/scripts/watch.sh opentdf.yaml ./opentdf start | ||
wait-on: | | ||
tcp:localhost:8080 | ||
log-output-if: true | ||
wait-for: 90s | ||
working-directory: platform | ||
|
||
- name: build the CLI | ||
run: go build . | ||
- name: build the CLI in test mode | ||
run: make build-test | ||
- name: set up the config | ||
run: cp otdfctl-example.yaml otdfctl.yaml | ||
- name: Setup Bats and bats libs | ||
uses: bats-core/[email protected] | ||
- run: tests/encrypt-decrypt.bats | ||
- run: tests/kas-grants.bats | ||
- run: tests/profile.bats | ||
- run: tests/kas-registry.bats | ||
- run: tests/namespaces.bats | ||
platform-ref: 'main' | ||
otdfctl-ref: ${{ github.event.pull_request.head.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
name: 'end-to-end' | ||
description: 'Run end-to-end tests for the otdfctl CLI' | ||
inputs: | ||
# Known issue: boolean defaults are treated as strings [https://stackoverflow.com/questions/76292948/github-action-boolean-input-with-default-value] | ||
platform-is-running: | ||
required: false | ||
default: 'false' | ||
description: 'If false, spin up the platform and its resources' | ||
platform-ref: | ||
required: false | ||
description: 'The ref to check out for the platform' | ||
default: 'main' | ||
otdfctl-ref: | ||
required: false | ||
description: 'The ref to check out for the otdfctl CLI' | ||
default: 'main' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Report on the run context | ||
shell: bash | ||
run: | | ||
if [ ${{ inputs.platform-is-running }} == 'true' ]; then | ||
echo "Platform is already running" | ||
else | ||
if [ "${{ inputs.platform-ref }}" == "" ]; then | ||
echo "Platform will be spun up from 'main'" | ||
else | ||
echo "Platform will be checked out at '${{ inputs.platform-ref }}' and spun up" | ||
fi | ||
fi | ||
if [ ${{ inputs.otdfctl-ref == github.event.pull_request.head.sha }} ]; then | ||
echo "otdfctl will be tested from the PR branch" | ||
else | ||
echo "otdfctl will be tested from 'main' or '${{ inputs.otdfctl-ref }}'" | ||
fi | ||
- name: Check out otdfctl CLI | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | ||
with: | ||
ref: ${{ inputs.otdfctl-ref }} | ||
path: otdfctl | ||
# Spin up the platform IFF it's not already running in the current workflow context | ||
- name: Check out platform | ||
if: ${{ inputs.platform-is-running == 'false' }} | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | ||
with: | ||
repository: opentdf/platform | ||
path: platform | ||
ref: ${{ inputs.platform-ref }} | ||
- name: Set up go (platform's go version) | ||
id: setup-go | ||
if: ${{ inputs.platform-is-running == 'false' }} | ||
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 | ||
with: | ||
go-version-file: 'platform/service/go.mod' | ||
check-latest: false | ||
cache-dependency-path: | | ||
platform/service/go.sum | ||
platform/protocol/go/go.sum | ||
platform/sdk/go.sum | ||
- name: Provide the platform with keys | ||
shell: bash | ||
if: ${{ inputs.platform-is-running == 'false' }} | ||
run: | | ||
.github/scripts/init-temp-keys.sh | ||
cp opentdf-dev.yaml opentdf.yaml | ||
working-directory: platform | ||
- name: Trust the generated certs | ||
if: ${{ inputs.platform-is-running == 'false' }} | ||
shell: bash | ||
run: | | ||
sudo chmod -R 777 ./keys | ||
sudo apt-get install -y ca-certificates | ||
sudo cp ./keys/localhost.crt /usr/local/share/ca-certificates | ||
sudo update-ca-certificates | ||
working-directory: platform | ||
- name: Spin up platform's containerized resources | ||
if: ${{ inputs.platform-is-running == 'false' }} | ||
shell: bash | ||
run: docker compose up -d --wait --wait-timeout 240 | ||
working-directory: platform | ||
- name: Provision realms/clients/users into idP | ||
if: ${{ inputs.platform-is-running == 'false' }} | ||
shell: bash | ||
run: go run ./service provision keycloak | ||
working-directory: platform | ||
- name: Provision test fixture policy | ||
if: ${{ inputs.platform-is-running == 'false' }} | ||
shell: bash | ||
run: go run ./service provision fixtures | ||
working-directory: platform | ||
- name: Start platform server in background | ||
if: ${{ inputs.platform-is-running == 'false' }} | ||
uses: JarvusInnovations/background-action@2428e7b970a846423095c79d43f759abf979a635 | ||
with: | ||
run: > | ||
go build -o opentdf -v service/main.go | ||
&& .github/scripts/watch.sh opentdf.yaml ./opentdf start | ||
wait-on: | | ||
tcp:localhost:8080 | ||
log-output-if: true | ||
wait-for: 90s | ||
working-directory: platform | ||
|
||
# Build the CLI and run tests | ||
- name: Set up go (CLI version, if needed) | ||
if: steps.setup-go.outcome != 'success' | ||
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 | ||
with: | ||
go-version-file: go.mod | ||
- name: Build the CLI | ||
shell: bash | ||
run: go build . | ||
working-directory: otdfctl | ||
- name: Build the CLI in test mode | ||
shell: bash | ||
run: make build-test | ||
working-directory: otdfctl | ||
- name: Set up the CLI config | ||
shell: bash | ||
run: cp otdfctl-example.yaml otdfctl.yaml | ||
working-directory: otdfctl | ||
- name: Setup Bats and bats libs | ||
uses: bats-core/[email protected] | ||
- name: Run Bats tests | ||
shell: bash | ||
working-directory: otdfctl | ||
run: bats e2e | ||
env: | ||
# Define 'bats' install location in ubuntu | ||
BATS_LIB_PATH: /usr/lib | ||
# Terminal width for testing printed output | ||
TEST_TERMINAL_WIDTH: 200 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters