Skip to content

Commit

Permalink
ci(app): split test server builds into separate ci job (trustbloc#723)
Browse files Browse the repository at this point in the history
Signed-off-by: Rolson Quadras <[email protected]>
  • Loading branch information
rolsonquadras authored Feb 13, 2024
1 parent d8a04c3 commit 9895005
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 29 deletions.
90 changes: 82 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ jobs:
CODECOV_UPLOAD_TOKEN: ${{ secrets.CODECOV_UPLOAD_TOKEN }}

SDKIntegrationTest:
runs-on: ubuntu-20.04
timeout-minutes: 30
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Set up Go
Expand All @@ -86,8 +86,55 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

BuildMockLoginConsentServer:
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Build docker images for test server
run: |
docker build -f ./images/mocks/loginconsent/Dockerfile --no-cache -t wallet-sdk/mock-login-consent:latest \
--build-arg GO_VER=1.21 \
--build-arg ALPINE_VER=3.18 .
- name: Save docker image as tar
run: |
docker save --output /tmp/mock-login-consent.tar wallet-sdk/mock-login-consent
- name: Upload image to artifact
uses: actions/upload-artifact@v4
with:
name: mock-login-consent
path: /tmp/mock-login-consent.tar

BuilMockTrustRegistryServer:
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Build docker images for test server
run: |
docker build -f ./images/mocks/trustregistry/Dockerfile --no-cache -t wallet-sdk/mock-trust-registry:latest \
--build-arg GO_VER=1.21 \
--build-arg ALPINE_VER=3.18 .
- name: Save docker image as tar
run: |
docker save --output /tmp/mock-trust-registry.tar wallet-sdk/mock-trust-registry
- name: Upload image to artifact
uses: actions/upload-artifact@v4
with:
name: mock-trust-registry
path: /tmp/mock-trust-registry.tar

iOSFlutterIntegrationTest:
runs-on: macos-12
needs: [ BuildMockLoginConsentServer, BuilMockTrustRegistryServer ]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -118,9 +165,17 @@ jobs:
echo '127.0.0.1 cognito-mock.trustbloc.local' | sudo tee -a /etc/hosts
brew install docker docker-compose
colima start
- name: Build docker images for test servers
- name: Download artifacts (Docker images) from previous workflows
uses: actions/download-artifact@v4
- name: Load mock-login-consent server
run: |
make build-integration-cli mock-login-consent-docker mock-trust-registry-docker build-krakend-plugin generate-test-keys
docker load --input mock-login-consent/mock-login-consent.tar
- name: Load mock test registry server
run: |
docker load --input mock-trust-registry/mock-trust-registry.tar
- name: Generate test cli and keys
run: |
make build-integration-cli generate-test-keys
- name: Setup env for integration test
run: |
make start-integration-env-flutter
Expand All @@ -141,9 +196,15 @@ jobs:
rm -rf demo/app/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
- name: Run tests on Simulator
run: make integration-test-flutter integration-test-ios
- name: Docker container status output
if: always()
run: |
docker images
docker ps -a
AndroidFlutterIntegrationTest:
runs-on: macOS-12
runs-on: macos-12
needs: [ BuildMockLoginConsentServer, BuilMockTrustRegistryServer ]
steps:
- name: checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -176,9 +237,17 @@ jobs:
echo '127.0.0.1 cognito-mock.trustbloc.local' | sudo tee -a /etc/hosts
brew install docker docker-compose
colima start
- name: Build docker images for test servers
- name: Download artifacts (Docker images) from previous workflows
uses: actions/download-artifact@v4
- name: Load mock-login-consent server
run: |
make build-integration-cli mock-login-consent-docker mock-trust-registry-docker build-krakend-plugin generate-test-keys
docker load --input mock-login-consent/mock-login-consent.tar
- name: Load mock test registry server
run: |
docker load --input mock-trust-registry/mock-trust-registry.tar
- name: Generate test cli and keys
run: |
make build-integration-cli generate-test-keys
- name: Setup env for integration test
run: |
make start-integration-env-flutter
Expand All @@ -197,7 +266,7 @@ jobs:
run: |
cd demo/app
flutter build apk --debug
- name: Run tests on Emulator
- name: Run flutter and android tests on Emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 32
Expand All @@ -206,3 +275,8 @@ jobs:
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: adb reverse tcp:8075 tcp:8075 && adb reverse tcp:8072 tcp:8072 && adb reverse tcp:9229 tcp:9229 && make integration-test-flutter integration-test-android
- name: Docker container status output
if: always()
run: |
docker images
docker ps -a
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mock-login-consent-docker:
@docker build -f ./images/mocks/loginconsent/Dockerfile --no-cache -t wallet-sdk/mock-login-consent:latest \
--build-arg GO_VER=$(GO_VER) \
--build-arg ALPINE_VER=$(GO_ALPINE_VER) \
--build-arg GO_IMAGE=$(GO_IMAGE) test/integration/loginconsent
--build-arg GO_IMAGE=$(GO_IMAGE) .

.PHONY: mock-trust-registry-docker
mock-trust-registry-docker:
Expand All @@ -99,7 +99,7 @@ build-krakend-plugin: clean
go build -buildmode=plugin -o /opt/workspace/wallet-sdk/test/integration/fixtures/krakend-config/plugins/http-client-no-redirect.so .

.PHONY: integration-test
integration-test: mock-login-consent-docker mock-trust-registry-docker build-krakend-plugin generate-test-keys
integration-test: mock-login-consent-docker mock-trust-registry-docker generate-test-keys
@cd test/integration && go mod tidy && ENABLE_COMPOSITION=true go test -count=1 -v -cover . -p 1 -timeout=10m -race

.PHONY: build-integration-cli
Expand Down
6 changes: 3 additions & 3 deletions images/mocks/loginconsent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ FROM golang:${GO_VER}-alpine${ALPINE_VER} as builder

RUN apk update && apk add git && apk add ca-certificates
RUN adduser -D -g '' appuser
COPY . $GOPATH/src/github.com/trustbloc/wallet-sdk/test/integration/loginconsent/
WORKDIR $GOPATH/src/github.com/trustbloc/wallet-sdk/test/integration/loginconsent/
COPY . $GOPATH/src/github.com/trustbloc/wallet-sdk/
WORKDIR $GOPATH/src/github.com/trustbloc/wallet-sdk/

RUN CGO_ENABLED=0 go build -o /usr/bin/mock-login-consent
RUN cd test/integration/loginconsent/ && CGO_ENABLED=0 go build -o /usr/bin/mock-login-consent

FROM scratch

Expand Down
6 changes: 3 additions & 3 deletions scripts/prepare_integration_test_flutter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ healthCheck() {

until [ $n -ge $maxAttempts ]
do
docker-compose -f docker-compose.yml logs --no-color >& docker-compose.log
cat ./docker-compose.log

docker ps -a

response=$(curl -H 'Cache-Control: no-cache' -o /dev/null -s -w "%{http_code}" "$2")
echo "running health check : httpResponseCode=$response"
Expand All @@ -68,8 +68,8 @@ healthCheck() {
}

# healthcheck
healthCheck did-resolver http://did-resolver.trustbloc.local:8072/healthcheck 200 180
healthCheck vc-rest http://localhost:8075/version 200 180
healthCheck did-resolver http://did-resolver.trustbloc.local:8072/healthcheck 200 180

if [ $healthCheckFailed == 1 ]
then
Expand Down
11 changes: 1 addition & 10 deletions test/integration/fixtures/.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,19 @@
# SPDX-License-Identifier: Apache-2.0
#

# vc services
VC_REST_IMAGE=ghcr.io/trustbloc-cicd/vc-server
VC_REST_IMAGE_TAG=v1.5.1-snapshot-aad1d14


# Remote JSON-LD context provider
CONTEXT_PROVIDER_URL=https://file-server.trustbloc.local:10096/ld-contexts.json

# Webhook configurations
SAMPLE_WEBHOOK_IMAGE=vcs/sample-webhook
SAMPLE_WEBHOOK_IMAGE_TAG=latest

# did-resolver
DID_RESOLVER_IMAGE=ghcr.io/trustbloc-cicd/did-resolver
DID_RESOLVER_IMAGE_TAG=v0.0.1-snapshot-58ab302
DID_RESOLVER_HOST=0.0.0.0
DID_RESOLVER_PORT=8072

# kms
KMS_IMAGE=ghcr.io/trustbloc/kms
KMS_IMAGE_TAG=v0.1.8
KMS_DATABASE_TYPE=mongodb

# mongodb
MONGODB_IMAGE=mongo
MONGODB_IMAGE_TAG=4.0.0
Expand Down
7 changes: 4 additions & 3 deletions test/integration/pkg/setup/oidc4ci/oidc4ci_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"github.com/google/uuid"
"golang.org/x/oauth2/clientcredentials"
"io"
"net/http"
"net/http/cookiejar"

"github.com/google/uuid"
"golang.org/x/oauth2/clientcredentials"

"golang.org/x/oauth2"

"github.com/trustbloc/wallet-sdk/test/integration/pkg/httprequest"
Expand Down Expand Up @@ -202,7 +203,7 @@ func InitiateAuthCodeIssuance() (string, error) {
return "", err
}
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("expected resp status OK but got %d", resp.StatusCode)
return "", fmt.Errorf("expected resp status OK but got %d : resp=%s", resp.StatusCode, string(b))
}

println("response %s", string(b))
Expand Down

0 comments on commit 9895005

Please sign in to comment.