-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(ci): added workflow for acceptance tests
Signed-off-by: manhtukhang <travis.khang@protonmail.com>
- Loading branch information
1 parent
8018921
commit 6aca064
Showing
4 changed files
with
196 additions
and
85 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Acceptance Test | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
vault-version: | ||
required: false | ||
type: string | ||
default: "lastest" | ||
vault-plugin-dir: | ||
required: false | ||
type: string | ||
default: "./test/plugins" | ||
nxr-version: | ||
required: false | ||
type: string | ||
default: "lastest" | ||
|
||
jobs: | ||
test: | ||
name: 'Test plugin on Vault v${{ inputs.vault-version }} + Nexus Repository v${{ inputs.nxr-version }}' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- | ||
name: Setup Vault CLI | ||
run: | | ||
curl -LO 'https://releases.hashicorp.com/vault/${{ inputs.vault-version }}/vault_${{ inputs.vault-version }}_linux_amd64.zip' &&\ | ||
unzip 'vault_${{ inputs.vault-version }}_linux_amd64.zip' &&\ | ||
install vault /usr/local/bin &&\ | ||
rm -rf ./vault* | ||
- | ||
name: Setup Bats and bats libs | ||
id: setup-bats | ||
uses: bats-core/bats-action@3.0.0 | ||
with: | ||
support-install: false | ||
detik-install: false | ||
file-install: false | ||
- | ||
name: Download plugin form build | ||
if: github.action_ref != 'v*' | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: vault-plugin-secrets-nexus-repository | ||
path: dist/bin | ||
- | ||
name: Run test | ||
shell: bash | ||
env: | ||
# BATS_LIB_PATH: ${{ steps.setup-bats.outputs.lib-path }} | ||
# TERM: xterm | ||
VAULT_VERSION: ${{ inputs.vault-version }} | ||
VAULT_PLUGIN_DIR: ${{ inputs.vault-plugin-dir }} | ||
NXR_VERSION: ${{ inputs.nxr-version }} | ||
#run: bats test/acceptance-tests.bats | ||
run: | | ||
chmod 755 -R ${VAULT_PLUGIN_DIR} | ||
bats test/acceptance-tests.bats |
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,58 @@ | ||
name: Acceptance Test | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
pre_job: | ||
# continue-on-error: true | ||
runs-on: ubuntu-latest | ||
outputs: | ||
should_skip: ${{ steps.skip_check.outputs.should_skip }} | ||
steps: | ||
- id: skip_check | ||
uses: fkirc/skip-duplicate-actions@v5 | ||
with: | ||
concurrent_skipping: 'same_content_newer' | ||
skip_after_successful_duplicate: 'true' | ||
cancel_others: 'true' | ||
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]' | ||
build: | ||
name: Build plugin executable binary | ||
needs: pre_job | ||
runs-on: ubuntu-latest | ||
if: needs.pre_job.outputs.should_skip != 'true' | ||
steps: | ||
- | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- | ||
name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: ./go.mod | ||
cache-dependency-path: ./go.sum | ||
- | ||
name: Build plugin | ||
id: build-plugin | ||
run: make build | ||
- | ||
name: Upload plugin | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: vault-plugin-secrets-nexus-repository | ||
path: dist/bin | ||
if-no-files-found: error | ||
test: | ||
needs: [pre_job, build] | ||
strategy: | ||
matrix: | ||
vault: ["1.18.2"] | ||
nexus: ["3.74.0"] | ||
uses: ./.github/workflows/_test-acceptance.tmpl.yaml | ||
with: | ||
vault-version: ${{ matrix.vault }} | ||
nxr-version: ${{ matrix.nexus }} | ||
vault-plugin-dir: ./dist/bin |
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,55 @@ | ||
name: ${DOCKER_COMPOSE_NAME:-vault-nexus-acceptance-tests} | ||
## | ||
services: | ||
nxr-tests: | ||
image: "sonatype/nexus3:${NXR_VERSION:-latest}" | ||
environment: | ||
NEXUS_SECURITY_RANDOMPASSWORD: "false" | ||
healthcheck: | ||
test: | ||
- CMD | ||
- curl | ||
- --fail | ||
- --silent | ||
- http://localhost:8081/service/rest/v1/status/writable | ||
interval: 10s | ||
timeout: 5s | ||
retries: 10 | ||
start_period: 40s | ||
ports: | ||
- "${NXR_SERVER_ADDR:-127.0.0.1}:${NXR_PORT:-8400}:8081" | ||
# | ||
vault-tests: | ||
image: "hashicorp/vault:${VAULT_VERSION:-latest}" | ||
environment: | ||
VAULT_DEV_ROOT_TOKEN_ID: "${VAULT_TOKEN:-root-token}" | ||
VAULT_DEV_LISTEN_ADDRESS: "0.0.0.0:8200" | ||
command: | ||
- vault | ||
- server | ||
- -dev | ||
- -dev-plugin-dir=/vault/plugins | ||
- -log-level=trace | ||
healthcheck: | ||
test: | ||
- CMD | ||
- vault | ||
- status | ||
- -address | ||
- http://localhost:8200 | ||
interval: 10s | ||
timeout: 5s | ||
retries: 10 | ||
start_period: 5s | ||
ports: | ||
- "${VAULT_SERVER_ADDR:-127.0.0.1}:${VAULT_PORT:-8200}:8200" | ||
cap_add: | ||
- IPC_LOCK | ||
volumes: | ||
- type: bind | ||
source: ".${VAULT_PLUGIN_DIR:-./dist/bin}" | ||
target: /vault/plugins | ||
read_only: true | ||
## | ||
networks: | ||
default: null |