Skip to content

Commit

Permalink
build: combine test-workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Kotzbauer <[email protected]>
  • Loading branch information
ckotzbauer committed May 8, 2022
1 parent 88f36a7 commit d076603
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 119 deletions.
116 changes: 0 additions & 116 deletions .github/workflows/test-registries.yml

This file was deleted.

101 changes: 99 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Setup AWS CLI
uses: unfor19/install-aws-cli-action@v1

- uses: azure/[email protected]
with:
version: 'v1.24.0'

- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
Expand All @@ -35,12 +42,102 @@ jobs:
- name: Build binary
run: make build

# - name: Prepare ACR secrets
# shell: bash
# run: |
# mkdir auth
#
# kubectl create secret docker-registry acr-secret \
# --docker-username="${{ secrets.TEST_ACR_USERNAME }}" \
# --docker-password="${{ secrets.TEST_ACR_PASSWORD }}" \
# --docker-server=sbomgitoperator.azurecr.io \
# --docker-email="${{ secrets.TEST_EMAIL }}" \
# -o json --dry-run=client | jq -r '.data.".dockerconfigjson"' > auth/acr.yaml

- name: Prepare ECR secrets
shell: bash
env:
AWS_ACCESS_KEY_ID: ${{ secrets.TEST_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: eu-central-1
run: |
mkdir auth
kubectl create secret docker-registry ecr-secret \
--docker-username=AWS \
--docker-password="$(aws ecr get-login-password)" \
--docker-server=055403865123.dkr.ecr.eu-central-1.amazonaws.com \
--docker-email="${{ secrets.TEST_EMAIL }}" \
-o json --dry-run=client | jq -r '.data.".dockerconfigjson"' > auth/ecr.yaml
- name: Prepare GAR secrets
shell: bash
env:
TEST_GAR_PASSWORD: ${{ secrets.TEST_GAR_PASSWORD }}
run: |
kubectl create secret docker-registry gar-secret \
--docker-username=_json_key \
--docker-password="$TEST_GAR_PASSWORD" \
--docker-server=europe-west3-docker.pkg.dev \
--docker-email="${{ secrets.TEST_EMAIL }}" \
-o json --dry-run=client | jq -r '.data.".dockerconfigjson"' > auth/gar.yaml
- name: Prepare GCR secrets
shell: bash
env:
TEST_GCR_PASSWORD: ${{ secrets.TEST_GCR_PASSWORD }}
run: |
kubectl create secret docker-registry gcr-secret \
--docker-username=_json_key \
--docker-password="$TEST_GCR_PASSWORD" \
--docker-server=gcr.io \
--docker-email="${{ secrets.TEST_EMAIL }}" \
-o json --dry-run=client | jq -r '.data.".dockerconfigjson"' > auth/gcr.yaml
- name: Prepare GHCR secrets
shell: bash
run: |
kubectl create secret docker-registry ghcr-secret \
--docker-username="${{ secrets.TEST_GHCR_USERNAME }}" \
--docker-password="${{ secrets.TEST_GHCR_PASSWORD }}" \
--docker-server=ghcr.io \
--docker-email="${{ secrets.TEST_EMAIL }}" \
-o json --dry-run=client | jq -r '.data.".dockerconfigjson"' > auth/ghcr.yaml
- name: Prepare Hub secrets
shell: bash
run: |
kubectl create secret docker-registry hub-secret \
--docker-username="${{ secrets.TEST_HUB_USERNAME }}" \
--docker-password="${{ secrets.TEST_HUB_PASSWORD }}" \
--docker-server=https://index.docker.io/v1/ \
--docker-email="${{ secrets.TEST_EMAIL }}" \
-o json --dry-run=client | jq -r '.data.".dockerconfigjson"' > auth/hub.yaml
- name: Prepare legacy GHCR secrets
shell: bash
env:
TEST_GCR_PASSWORD: ${{ secrets.TEST_GCR_PASSWORD }}
run: |
cat << EOF > .dockercfg
{
"ghcr.io": { "username": "${{ secrets.TEST_GHCR_USERNAME }}", "password": "${{ secrets.TEST_GHCR_PASSWORD }}" }
}
EOF
kubectl create secret generic ghcr-secret \
--from-file=.dockercfg \
--type=kubernetes.io/dockercfg \
-o json --dry-run=client | jq -r '.data.".dockercfg"' > auth/legacy-ghcr.yaml
- name: Unit tests
run: make test
run: |
make test
make test-registries
- uses: codecov/codecov-action@v3
with:
files: cover.out
files: cover.out,cover-registries.out

- name: Build image
uses: docker/build-push-action@v3
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ vet:
go vet ./...

test-registries:
go test github.com/ckotzbauer/sbom-operator/internal/registry
go test github.com/ckotzbauer/sbom-operator/internal/registry -coverprofile cover-registries.out

test:
go test $(shell go list ./... | grep -v sbom-operator/internal/registry) -coverprofile cover.out

0 comments on commit d076603

Please sign in to comment.