Skip to content

feat(ci): make e2e test workflow reusable #1

feat(ci): make e2e test workflow reusable

feat(ci): make e2e test workflow reusable #1

Workflow file for this run

name: 'end-to-end'
on:
pull_request:
branches:
- main
paths-ignore:
- '**/*.yaml'
- '**/*.md'
- LICENSE
- CODEOWNERS
- '.gitignore'
workflow_call:
inputs:
platform-is-running:
required: false
description: 'If false, spin up the platform and its resources'
default: false
type: boolean
platform-ref:
required: false
description: 'The ref to check out for the platform'
default: 'main'
type: string
otdfctl-ref:
required: false
description: 'The ref to check out for the otdfctl CLI'
default: 'main'
type: string
jobs:
end-to-end:
name: otdfctl CLI e2e tests
runs-on: ubuntu-latest
env:
# Define 'bats' install location in ubuntu
BATS_LIB_PATH: /usr/lib
# Terminal width for testing printed output
TEST_TERMINAL_WIDTH: 200
# Read the inputs into the environment
PLATFORM_IS_RUNNING: '${{ inputs.platform-is-running }}'
PLATFORM_REF: '${{ inputs.platform-ref }}'
OTDFCTL_REF: '${{ inputs.otdfctl-ref }}'
steps:
- name: Check out otdfctl CLI
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
ref: ${{ env.OTDFCTL_REF }}
# Spin up the platform IFF it's not already running in the current workflow context
- name: Check out platform
if: ${{ ! env.PLATFORM_IS_RUNNING }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
repository: opentdf/platform
path: platform
ref: ${{ env.PLATFORM_REF }}
- name: Set up go (platform's go version)
id: setup-go
if: ${{ ! env.PLATFORM_IS_RUNNING }}
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
if: ${{ ! env.PLATFORM_IS_RUNNING }}
run: |
.github/scripts/init-temp-keys.sh
cp opentdf-dev.yaml opentdf.yaml
working-directory: platform
- name: Trust the generated certs
if: ${{ ! env.PLATFORM_IS_RUNNING }}
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: ${{ ! env.PLATFORM_IS_RUNNING }}
run: docker compose up -d --wait --wait-timeout 240
working-directory: platform
- name: Provision realms/clients/users into idP
if: ${{ ! env.PLATFORM_IS_RUNNING }}
run: go run ./service provision keycloak
working-directory: platform
- name: Provision test fixture policy
if: ${{ ! env.PLATFORM_IS_RUNNING }}
run: go run ./service provision fixtures
working-directory: platform
- name: Start platform server in background
if: ${{ ! env.PLATFORM_IS_RUNNING }}
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 (if needed)
if: steps.setup-go.outcome != 'success'
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
with:
go-version-file: go.mod
- name: Build the CLI
run: go build .
- name: Build the CLI in test mode
run: make build-test
- name: Set up the CLI 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