Skip to content

Test secrets manager (#177) #386

Test secrets manager (#177)

Test secrets manager (#177) #386

Workflow file for this run

name: Tests
on:
push:
branches: [ main ]
paths:
- 'tools/**'
- 'internal/**'
- '*.go'
- 'go.*'
pull_request:
branches: [ main ]
paths:
- 'tools/**'
- 'internal/**'
- '*.go'
- 'go.*'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
services:
vaultwarden:
image: vaultwarden/server:1.32.0
env:
ADMIN_TOKEN: test1234
I_REALLY_WANT_VOLATILE_STORAGE: "true"
DISABLE_ICON_DOWNLOAD: "true"
LOGIN_RATELIMIT_SECONDS: "1"
LOGIN_RATELIMIT_MAX_BURST: "1000000"
ADMIN_RATELIMIT_SECONDS: "1"
ADMIN_RATELIMIT_MAX_BURST: "1000000"
ports:
- 8080:80
options: >-
--health-cmd "curl -f http://localhost:80/"
--health-interval 30s
--health-timeout 10s
--health-retries 5
--health-start-period 15s
steps:
- id: go-cache-paths
run: |
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- id: binaries
run: |
echo "LOCAL_BINARIES=$GITHUB_WORKSPACE/bin" >> $GITHUB_OUTPUT
echo "BWCLI_VERSION=2023.2.0" >> $GITHUB_OUTPUT
- name: Check out repository code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '>=1.22.0'
# Cache go build cache, used to speedup go test
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.GOCACHE }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
# Cache go mod cache, used to speedup builds
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.GOMODCACHE }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Binaries Cache
uses: actions/cache@v3
with:
path: ${{ steps.binaries.outputs.LOCAL_BINARIES }}
key: ${{ steps.binaries.outputs.BWCLI_VERSION }}
- name: Download Binaries
run: |
echo "${{ steps.binaries.outputs.LOCAL_BINARIES }}" >> $GITHUB_PATH
if [[ -d "${{ steps.binaries.outputs.LOCAL_BINARIES }}" ]]; then
exit 0
fi
wget https://github.com/bitwarden/clients/releases/download/cli-v${{ steps.binaries.outputs.BWCLI_VERSION }}/bw-linux-${{ steps.binaries.outputs.BWCLI_VERSION }}.zip
mkdir -p ${{ steps.binaries.outputs.LOCAL_BINARIES }}
unzip bw-linux-${{ steps.binaries.outputs.BWCLI_VERSION }}.zip
chmod +x bw
mv bw ${{ steps.binaries.outputs.LOCAL_BINARIES }}
- name: Build
run: go build -v ./...
- name: Test with Embedded Client
run: go test -coverprofile=profile_embedded.cov -v ./...
env:
VAULTWARDEN_HOST: "127.0.0.1"
VAULTWARDEN_PORT: "8080"
TF_ACC: "1"
TEST_USE_EMBEDDED_CLIENT: "1"
- name: Test with Official Client
run: go test -coverprofile=profile_official.cov -timeout 1000s -failfast -v ./...
env:
VAULTWARDEN_HOST: "127.0.0.1"
VAULTWARDEN_PORT: "8080"
TF_ACC: "1"
- name: Combine Coverage
run: cat profile_embedded.cov profile_official.cov | sort -r | uniq > profile.cov
- name: Code Coverage
continue-on-error: true
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov