Skip to content
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

test: Add venom test-suites #11

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
name: build

on:
push:
branches: ["main"]
workflow_call: {}

jobs:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/main-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: release

on:
push:
# run only against tags
branches:
- main

permissions:
contents: write
packages: write
# issues: write

jobs:
build:
uses: ./.github/workflows/build.yaml
secrets: inherit

integration-tests:
needs: build
uses: ./.github/workflows/test.yaml
secrets: inherit

5 changes: 5 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ jobs:
needs:
- commitlint
uses: ./.github/workflows/build.yaml
secrets: inherit

test:
needs: build
uses: ./.github/workflows/test.yaml
secrets: inherit
9 changes: 7 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ jobs:
build:
uses: ./.github/workflows/build.yaml
secrets: inherit

integration-tests:
needs: build
uses: ./.github/workflows/test.yaml
secrets: inherit

docker-build:
needs: build
needs: integration-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -37,7 +42,7 @@ jobs:
- run: KO_DOCKER_REPO=ghcr.io/ovh/okms-cli ko build --tags ${{ github.ref_name }},latest --push --bare --platform=linux/arm64,linux/amd64 ./cmd/okms

goreleaser:
needs: build
needs: integration-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: test

on:
workflow_call: {}


jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-build-env
- name: Build CLI
run: go build -cover ./cmd/okms
- name: Setup Venom
run: |
wget https://github.com/ovh/venom/releases/download/v1.2.0/venom.linux-amd64
mv venom.linux-amd64 venom
chmod +x venom
- name: Setup okms config file
run: |
echo "${{secrets.CERTIFICATE}}" > tls.crt
echo "${{secrets.PRIVATE_KEY}}" > tls.key

cat > okms.yaml <<-EOF
version: 1
profile: default
profiles:
default: # default profile
http:
endpoint: ${{secrets.KMS_HTTP_ENDPOINT}}
auth:
type: mtls
cert: $(pwd)/tls.crt
key: $(pwd)/tls.key
EOF
- name: Test connectivity to KMS dmain
run: ./okms keys ls -d -c okms.yaml
- name: Execute tests
run: make -C tests
- uses: actions/upload-artifact@v4
with:
name: test_results
path: |
./tests/out/test_results.html
./tests/out/venom.log
retention-days: 5
if: always()
- uses: actions/upload-artifact@v4
with:
name: coverage
path: |
./tests/out/coverage.txt
./tests/out/coverage.html
retention-days: 5

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ tmp.CHANGELOG.md
/git-cliff-*

.config/
.cache/
.cache/

# Venom tests output
tests/out
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# okms-cli
[![build](https://github.com/ovh/okms-cli/actions/workflows/build.yaml/badge.svg?branch=main)](https://github.com/ovh/okms-cli/actions/workflows/build.yaml)
[![build](https://github.com/ovh/okms-cli/actions/workflows/main-branch.yaml/badge.svg?branch=main)](https://github.com/ovh/okms-cli/actions/workflows/main-branch.yaml)
[![license](https://img.shields.io/badge/license-Apache%202.0-red.svg?style=flat)](https://raw.githubusercontent.com/ovh/okms-sdk-go/master/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/ovh/okms-cli)](https://goreportcard.com/report/github.com/ovh/okms-cli)

The CLI to interact with your [OVHcloud KMS](https://help.ovhcloud.com/csm/en-ie-kms-quick-start?id=kb_article_view&sysparm_article=KB0063362) services.
Expand Down
6 changes: 6 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
test:
rm -Rf out
../venom run --html-report --output-dir=out --var-from-file cfg/vars.yaml -v .
go tool covdata percent -i out/coverage
go tool covdata textfmt -i out/coverage -o out/coverage.txt
go tool cover -html out/coverage.txt -o out/coverage.html
2 changes: 2 additions & 0 deletions tests/cfg/vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cmd_path: ../okms
cfg_path: ../okms.yaml
Loading
Loading