blob: d43af660221c4c1a23860e4cbfda392d51e9940a [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software 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.
# To learn more about GitHub Actions in Apache Beam check the CI.md
name: Tour of Beam Go integration tests
on:
push:
branches: ['master', 'release-*']
tags: 'v*'
paths:
- '.github/workflows/tour_of_beam_backend_integration.yml'
- 'learning/tour-of-beam/backend/**'
- 'playground/backend/**'
pull_request:
branches: ['master', 'release-*']
tags: 'v*'
paths:
- '.github/workflows/tour_of_beam_backend_integration.yml'
- 'learning/tour-of-beam/backend/**'
- 'playground/backend/**'
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
env:
TOB_LEARNING_ROOT: ./samples/learning-content
# firebase
GOOGLE_CLOUD_PROJECT: demo-test-proj
FIREBASE_AUTH_EMULATOR_HOST: localhost:9099
# datastore
DATASTORE_PROJECT_ID: demo-test-proj
DATASTORE_EMULATOR_HOST: localhost:8081
DATASTORE_EMULATOR_DATADIR: ./datadir
# playground API
PLAYGROUND_ROUTER_HOST: localhost:8000
# GCF
PORT_SDK_LIST: 8801
PORT_GET_CONTENT_TREE: 8802
PORT_GET_UNIT_CONTENT: 8803
PORT_GET_USER_PROGRESS: 8804
PORT_POST_UNIT_COMPLETE: 8805
PORT_POST_USER_CODE: 8806
PORT_POST_DELETE_PROGRESS: 8807
jobs:
integration:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./learning/tour-of-beam/backend
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
# pin to the biggest Go version supported by Cloud Functions runtime
go-version: '1.16'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
- name: Build Playground router image
run: ./gradlew -i playground:backend:containers:router:docker
working-directory: ${{ env.GITHUB_WORKSPACE }}
# 1. Start emulators
- name: Start emulators
run: docker-compose up -d
# 2. start function-framework processes in BG
- name: Compile CF
run: go build -o ./tob_function cmd/main.go
- name: Run getSdkList in background
run: PORT=${{ env.PORT_SDK_LIST }} FUNCTION_TARGET=getSdkList ./tob_function &
- name: Run getContentTree in background
run: PORT=${{ env.PORT_GET_CONTENT_TREE }} FUNCTION_TARGET=getContentTree ./tob_function &
- name: Run getUnitContent in background
run: PORT=${{ env.PORT_GET_UNIT_CONTENT }} FUNCTION_TARGET=getUnitContent ./tob_function &
- name: Run getUserProgress in background
run: PORT=${{ env.PORT_GET_USER_PROGRESS }} FUNCTION_TARGET=getUserProgress ./tob_function &
- name: Run postUnitComplete in background
run: PORT=${{ env.PORT_POST_UNIT_COMPLETE }} FUNCTION_TARGET=postUnitComplete ./tob_function &
- name: Run postUserCode in background
run: PORT=${{ env.PORT_POST_USER_CODE }} FUNCTION_TARGET=postUserCode ./tob_function &
- name: Run postDeleteProgress in background
run: PORT=${{ env.PORT_POST_DELETE_PROGRESS }} FUNCTION_TARGET=postDeleteProgress ./tob_function &
# 3. Load data in datastore: run CD step on samples/learning-content
- name: Run CI/CD to populate datastore
run: go run cmd/ci_cd/ci_cd.go
# 4. run integration tests
- name: Go integration tests
run: go test -v --tags integration ./integration_tests/...
- name: Stop emulators
if: always()
run: docker-compose down
# 5. Compare storage/datastore/index.yml VS generated
- name: Check index.yaml
run: |
diff -q "${{ env.DATASTORE_EMULATOR_DATADIR }}/WEB-INF/index.yaml" \
internal/storage/index.yaml \
|| ( echo "index.yaml mismatch"; exit 1)