From 4fca7028ce8f197c9123e2bb454d7576f8091548 Mon Sep 17 00:00:00 2001 From: Matej Velikonja Date: Wed, 18 Jan 2023 15:54:32 +0100 Subject: [PATCH] feat(gh-actions): add action for running tests (#3) --- .github/workflows/main.yml | 50 +++++++++++++++++++++++++++++++++++++- README.md | 4 ++- docker-compose.yml | 4 +-- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dfba7f6..6791398 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Lint +name: Tests on: push: @@ -26,3 +26,51 @@ jobs: with: version: latest args: --timeout 3m + + tests: + runs-on: ubuntu-latest + + strategy: + matrix: + vaultVer: [ "1.12.2", "1.11.6" ] + + services: + vault: + image: vault:${{ matrix.vaultVer }} + ports: + - 8200:8200 + options: >- + --cap-add IPC_LOCK + env: + VAULT_DEV_ROOT_TOKEN_ID: testtoken + VAULT_DEV_LISTEN_ADDRESS: 0.0.0.0:8200 + VAULT_LOG_LEVEL: trace + + steps: + - id: go-cache-paths + run: | + echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT + echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: "1.x" + + - name: Go Build Cache + uses: actions/cache@v3 + with: + path: ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + + - name: Go Mod Cache + uses: actions/cache@v3 + with: + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + + - name: Run tests + run: make test diff --git a/README.md b/README.md index ddc375b..4c0c0aa 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # k8s-vault-operator + +![Tests](https://github.com/kiwicom/k8s-vault-operator/actions/workflows/main.yml/badge.svg) + Syncing vault secrets to k8s secrets. ## Description @@ -580,4 +583,3 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - diff --git a/docker-compose.yml b/docker-compose.yml index c7dce44..ea750dd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,9 +7,10 @@ services: - IPC_LOCK ports: - "8200:8200" - command: server -dev --log-level=trace -dev-listen-address=0.0.0.0:8200 environment: VAULT_DEV_ROOT_TOKEN_ID: testtoken + VAULT_DEV_LISTEN_ADDRESS: 0.0.0.0:8200 + VAULT_LOG_LEVEL: trace runner: image: golang:alpine @@ -21,4 +22,3 @@ services: VAULT_TOKEN: testtoken volumes: - .:/app -