-
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
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/bats-action@2.0.0 | ||
- 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