-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Phase 1 — automated auth bootstrap and integration test infrastructure #35
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
Open
Jaydeep869
wants to merge
6
commits into
mindersec:main
Choose a base branch
from
Jaydeep869:feature/phase1-bootstrap-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f05f089
feat: Phase 1 auth bootstrap + test infrastructure
Jaydeep869 226de55
fix: address reviewer feedback on Phase 1 CI workflow and task targets
Jaydeep869 e7d064c
fix(ci): patch compose to use pre-built images and fix config generation
Jaydeep869 57ec3f3
fix(ci): guard teardown steps against missing compose file
Jaydeep869 2bf3b2b
fix(ci): correct minder CLI download URL and guard test reporter
Jaydeep869 5fdbbb0
fix(ci): use releases API to find minder CLI asset URL dynamically
Jaydeep869 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,230 @@ | ||
| --- | ||
| name: Integration Tests | ||
|
|
||
| on: | ||
| # Manual trigger for on-demand runs. | ||
| # NOTE: we always test mindersec/minder@main to prevent | ||
| # impersonation attacks where a fork's malicious Makefile/compose | ||
| # code could run with access to this repo's secrets. | ||
| workflow_dispatch: | ||
| inputs: | ||
| test_tags: | ||
| description: 'Robot Framework tag filter (e.g. "core", "smoke")' | ||
| required: false | ||
| default: '' | ||
|
|
||
| # Weekly scheduled run | ||
| schedule: | ||
| - cron: "0 6 * * 1" # Every Monday at 6:00 AM UTC | ||
|
|
||
| # Run on PRs to validate test infrastructure changes | ||
| pull_request: | ||
| paths: | ||
| - "scripts/**" | ||
| - "minder-tests/**" | ||
| - "resources/**" | ||
| - "smoke-test-config*.yaml" | ||
| - ".github/workflows/integration-tests.yml" | ||
| - "requirements.txt" | ||
|
|
||
| concurrency: | ||
| group: integration-tests-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| integration-test: | ||
| name: Run Integration Tests | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| # ------------------------------------------------------------------ | ||
| # Checkout smoke-tests. | ||
| # We test against mindersec/minder@main using pre-built images — | ||
| # we do NOT run any Makefile from the minder repo. | ||
| # ------------------------------------------------------------------ | ||
| - name: Checkout smoke-tests | ||
| uses: actions/checkout@v4 | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Install test dependencies directly on the runner. | ||
| # No container image needed — the runner already has Python. | ||
| # ------------------------------------------------------------------ | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
| cache: pip | ||
|
|
||
| - name: Install Robot Framework and dependencies | ||
| run: pip install -r requirements.txt | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Install minder CLI from the latest published GitHub release. | ||
| # Avoids building from source (~10 min saved). | ||
| # ------------------------------------------------------------------ | ||
| - name: Install minder CLI | ||
| run: | | ||
| # Fetch the download URL for the linux amd64 tarball directly from | ||
| # the releases API — avoids guessing the exact filename format | ||
| # (goreleaser strips the 'v' prefix: v0.1.2 -> minder_0.1.2_linux_amd64.tar.gz) | ||
| ASSET_URL=$(curl -sf https://api.github.com/repos/mindersec/minder/releases/latest \ | ||
| | jq -r '.assets[] | ||
| | select(.name | test("linux_amd64\\.tar\\.gz$")) | ||
| | .browser_download_url') | ||
|
|
||
| if [ -z "${ASSET_URL}" ]; then | ||
| echo "ERROR: could not find a linux_amd64 tarball in the latest release assets." | ||
| echo "Available assets:" | ||
| curl -sf https://api.github.com/repos/mindersec/minder/releases/latest \ | ||
| | jq -r '.assets[].name' | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Downloading minder CLI from: ${ASSET_URL}" | ||
| curl -fsSL "${ASSET_URL}" | tar -xz -C /usr/local/bin minder | ||
| minder version | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Fetch the minder docker-compose.yaml from main and patch it to | ||
| # use pre-built ghcr.io images instead of local build directives. | ||
| # The minder compose file has `build: context: .` for the server | ||
| # and migrate services — we replace these with the published image. | ||
| # ------------------------------------------------------------------ | ||
| - name: Fetch and patch Minder docker-compose | ||
| run: | | ||
| curl -sLo docker-compose.minder.yaml \ | ||
| https://raw.githubusercontent.com/mindersec/minder/main/docker-compose.yaml | ||
|
|
||
| # Install yq to patch the compose file | ||
| sudo wget -qO /usr/local/bin/yq \ | ||
| https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | ||
| sudo chmod +x /usr/local/bin/yq | ||
|
|
||
| # Replace build directives with ghcr.io pre-built images | ||
| yq e ' | ||
| del(.services.minder.build) | | ||
| .services.minder.image = "ghcr.io/mindersec/minder:latest" | | ||
| del(.services.migrate.build) | | ||
| .services.migrate.image = "ghcr.io/mindersec/minder:latest" | ||
| ' -i docker-compose.minder.yaml | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # minder needs a few config files and SSH keys that make bootstrap | ||
| # normally generates. Recreate the minimal set here. | ||
| # ------------------------------------------------------------------ | ||
| - name: Generate minder runtime config | ||
| run: | | ||
| # Fetch config templates from minder main | ||
| curl -sLo server-config.yaml \ | ||
| https://raw.githubusercontent.com/mindersec/minder/main/config/server-config.yaml.example | ||
| curl -sLo flags-config.yaml \ | ||
| https://raw.githubusercontent.com/mindersec/minder/main/flags-config.yaml || echo "{}" > flags-config.yaml | ||
|
|
||
| # Generate the SSH keys minder expects | ||
| mkdir -p .ssh .secrets | ||
| openssl genrsa -out .ssh/access_token_rsa 2048 2>/dev/null | ||
| openssl rsa -in .ssh/access_token_rsa -pubout -out .ssh/access_token_rsa.pub 2>/dev/null | ||
| openssl genrsa -out .ssh/refresh_token_rsa 2048 2>/dev/null | ||
| openssl rsa -in .ssh/refresh_token_rsa -pubout -out .ssh/refresh_token_rsa.pub 2>/dev/null | ||
| openssl rand -base64 32 > .ssh/token_key_passphrase | ||
| # Placeholder GitHub App key (real one not needed for core tests) | ||
| openssl genrsa -out .secrets/github-app.pem 2048 2>/dev/null | ||
| echo "Config files and SSH keys ready." | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Start the stack. --wait blocks until all healthchecks pass. | ||
| # No separate health-check polling needed. | ||
| # ------------------------------------------------------------------ | ||
| - name: Start Minder Docker stack | ||
| run: | | ||
| docker compose -f docker-compose.minder.yaml pull --quiet | ||
| docker compose -f docker-compose.minder.yaml up -d --wait | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Bootstrap: create test user, get offline token, enroll user, | ||
| # extract project ID. Script writes MINDER_PROJECT to $GITHUB_ENV. | ||
| # ------------------------------------------------------------------ | ||
| - name: Bootstrap test user and project | ||
| run: ./scripts/bootstrap.sh | ||
| env: | ||
| KEYCLOAK_URL: http://localhost:8081 | ||
| MINDER_API_URL: http://localhost:8080 | ||
| MINDER_BINARY: /usr/local/bin/minder | ||
| OFFLINE_TOKEN_OUTPUT_PATH: ${{ github.workspace }}/offline.token | ||
| CLIENT_ID: smoke-test-client | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Run Robot Framework tests directly on the runner. | ||
| # MINDER_PROJECT is set by bootstrap.sh via $GITHUB_ENV and is | ||
| # available here as a shell env var — do NOT use ${{ env.X }} syntax | ||
| # for vars set in previous steps (those are static at parse time). | ||
| # ------------------------------------------------------------------ | ||
| - name: Run smoke tests | ||
| run: | | ||
| EXTRA_ARGS="" | ||
| if [ -n "${{ github.event.inputs.test_tags }}" ]; then | ||
| EXTRA_ARGS="-i ${{ github.event.inputs.test_tags }}" | ||
| fi | ||
| robot \ | ||
| --outputdir results \ | ||
| --pythonpath . \ | ||
| --xunit results/xoutput.xml \ | ||
| --loglevel INFO \ | ||
| ${EXTRA_ARGS} \ | ||
| minder-tests/ | ||
| env: | ||
| MINDER_CONFIG: ${{ github.workspace }}/smoke-test-config.yaml | ||
| MINDER_OFFLINE_TOKEN_PATH: ${{ github.workspace }}/offline.token | ||
| MINDER_TEST_ORG: ${{ secrets.MINDER_TEST_ORG }} | ||
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| # MINDER_PROJECT is injected automatically from $GITHUB_ENV | ||
| # (set by bootstrap.sh) — no need to reference it here explicitly | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Results | ||
| # ------------------------------------------------------------------ | ||
| - name: Upload test results | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: robot-test-results | ||
| path: results/ | ||
| retention-days: 30 | ||
|
|
||
| - name: Publish test report | ||
| # Only run if the results file was actually created (tests ran) | ||
| if: always() && hashFiles('results/xoutput.xml') != '' | ||
| uses: dorny/test-reporter@v1 | ||
| with: | ||
| name: "Integration Test Results" | ||
| path: results/xoutput.xml | ||
| reporter: java-junit | ||
| fail-on-error: false | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Teardown | ||
| # All three steps guard against docker-compose.minder.yaml not | ||
| # existing (e.g. when an earlier step failed before creating it). | ||
| # ------------------------------------------------------------------ | ||
| - name: Show Minder logs on failure | ||
| if: failure() | ||
| run: | | ||
| if [ -f docker-compose.minder.yaml ]; then | ||
| docker compose -f docker-compose.minder.yaml logs minder --tail=100 | ||
| docker compose -f docker-compose.minder.yaml logs keycloak --tail=50 | ||
| else | ||
| echo "docker-compose.minder.yaml not found — stack was never started." | ||
| fi | ||
|
|
||
| - name: Teardown Minder stack | ||
| if: always() | ||
| run: | | ||
| if [ -f docker-compose.minder.yaml ]; then | ||
| docker compose -f docker-compose.minder.yaml down -v --remove-orphans | ||
| else | ||
| echo "docker-compose.minder.yaml not found — nothing to tear down." | ||
| fi | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -17,3 +17,5 @@ config.yaml | |
| log.html | ||
| output.xml | ||
| report.html | ||
| # integration test generated files | ||
| minder-project-id | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two should be
ghcr.io/mindersec/minder/server:latest