Skip to content

Commit 1891360

Browse files
authored
GitHub Action for integration tests (base infrastructure) (feast-dev#4)
Builds, tests and runs Docker container for Feast core as well as needed services (Kafka, Redis and PostgreSQL). Uses a self-hosted agent VM (deployed on Azure) to speed up build thanks to Docker layer caching. The Docker Action automatically runs whenever a PR is made.
1 parent 88b955a commit 1891360

8 files changed

Lines changed: 158 additions & 1 deletion

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: ci
2+
3+
on:
4+
# Trigger the workflow on push or pull request,
5+
# but only for the master branch
6+
push:
7+
branches:
8+
- master
9+
pull_request:
10+
branches:
11+
- master
12+
13+
jobs:
14+
15+
build-and-test:
16+
17+
# Run the job on a self-hosted agent VM. The VM will cache Docker layers, which considerably speeds up the build.
18+
runs-on: self-hosted
19+
steps:
20+
21+
# Delete any files left from the previous build, including files owned by root created by Docker in mounted volumes.
22+
- name: Clean current directory
23+
run: shopt -s dotglob; sudo rm -rf *
24+
25+
# Checkout sources from Git
26+
- uses: actions/checkout@v2
27+
28+
# Build base CI image, with dependencies such as Go and Python.
29+
# This image seldom changes, so thanks to layer caching this usually completes in seconds.
30+
- name: Build CI image
31+
uses: docker/build-push-action@v1
32+
with:
33+
username: ${{ secrets.CONTAINERREGISTRY_USERNAME }}
34+
password: ${{ secrets.CONTAINERREGISTRY_PASSWORD }}
35+
repository: ${{ secrets.CONTAINERREGISTRY_IMAGENAMEBASE }}-ci
36+
registry: ${{ secrets.CONTAINERREGISTRY_URL }}
37+
dockerfile: infra/docker/ci/Dockerfile
38+
tags: v${{ github.sha }}
39+
40+
41+
# Cache the Maven repository across runs.
42+
- name: Cache Maven repository
43+
id: cache-maven
44+
uses: actions/cache@v1
45+
with:
46+
path: .m2
47+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
48+
restore-keys: |
49+
${{ runner.os }}-maven-
50+
51+
# Generate the Maven cache if needed by running a throwaway build of Feast.
52+
- name: Generate Maven cache
53+
if: steps.cache-maven.outputs.cache-hit != 'true'
54+
run: docker run --rm --user $(id -u):$(id -g) -v $PWD:/build $IMAGE bash -c "cd /build && mvn -Dmaven.repo.local=/build/.m2/repository -Dgpg.skip=true -B verify -DskipTests"
55+
env:
56+
IMAGE: ${{ secrets.CONTAINERREGISTRY_URL }}/${{ secrets.CONTAINERREGISTRY_IMAGENAMEBASE }}-ci:v${{ github.sha }}
57+
58+
# "docker-compose up --build" builds and starts docker images.
59+
# Images fetched from a repository, such as Kafka, will not be built, so this
60+
# step will only build the Feast Core image.
61+
# After this step, the specified containers have been started and Docker Core
62+
# has successfully connected to its required services (such as PostgreSQL).
63+
- name: Start local Feast environment
64+
run: |
65+
docker-compose -f infra/docker-compose/docker-compose.yml up -d --build core redis kafka db
66+
for i in {1..12}; do nc -zv localhost 6565 && break; echo "Waiting for Feast Core to come online on port 6565..."; sleep 10; done
67+
env:
68+
COMPOSE_PROJECT_NAME: feast
69+
FEAST_VERSION: v${{ github.sha }}
70+
FEAST_CORE_IMAGE: ${{ secrets.CONTAINERREGISTRY_URL }}/${{ secrets.CONTAINERREGISTRY_IMAGENAMEBASE }}-core
71+
FEAST_CORE_CONFIG: direct-runner.yml
72+
FEAST_SERVING_IMAGE: gcr.io/kf-feast/feast-serving
73+
FEAST_ONLINE_SERVING_CONFIG: online-serving.yml
74+
FEAST_ONLINE_STORE_CONFIG: redis-store.yml
75+
76+
# Login to Azure Container Registry.
77+
- name: Login to Azure Container Registry
78+
uses: azure/docker-login@v1
79+
with:
80+
login-server: ${{ secrets.CONTAINERREGISTRY_URL }}
81+
username: ${{ secrets.CONTAINERREGISTRY_USERNAME }}
82+
password: ${{ secrets.CONTAINERREGISTRY_PASSWORD }}
83+
84+
# Promote successfully tested container to Azure Container Registry.
85+
- name: Push image to ACR
86+
run: |
87+
docker-compose -f infra/docker-compose/docker-compose.yml push core
88+
env:
89+
FEAST_VERSION: v${{ github.sha }}
90+
FEAST_CORE_IMAGE: ${{ secrets.CONTAINERREGISTRY_URL }}/${{ secrets.CONTAINERREGISTRY_IMAGENAMEBASE }}-core

docs/cicd/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# FarFetch CI setup
2+
3+
The CI setup ensures that PRs on GitHub are automatically tested before being merging to *master*. The CI jobs defined under
4+
5+
[.github/workflows]: ../../.github/workflows
6+
7+
run compilation, unit and end-to-end tests using GitHub Workflows.
8+
9+
## Agent configuration
10+
11+
1. Spin an Azure VM with Ubuntu 18.04. Choose e.g. a B4ms instance (burstable VM with 4 cores)
12+
2. Install prerequisites:
13+
14+
15+
```
16+
sudo apt update
17+
sudo apt install docker.io
18+
sudo usermod -aG docker $USER
19+
20+
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
21+
sudo chmod +x docker-compose
22+
```
23+
24+
3. Follow the actions to [add a self-hosted runner to your repository](https://help.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners)
25+
4. Follow the actions to [configure the self-hosted runner as a service](https://help.github.com/en/actions/hosting-your-own-runners/configuring-the-self-hosted-runner-application-as-a-service)
26+
27+
28+
29+
## One-time CI configuration
30+
31+
Create an Azure Container Registry named *acrffgithubci*. Make sure to Enable Admin user.
32+
33+
![Deploy ACR](deploy-acr.png)
34+
35+
Once the ACR instance is deployed, fetch the password from the Access keys section:
36+
37+
![ACR password](acr-password.png)
38+
39+
Populate the GitHub secrets settings with the ACR configuration:
40+
41+
![](create-secrets.png)
42+
43+
- CONTAINERREGISTRY_IMAGENAMEBASE=farfetchfeast
44+
- CONTAINERREGISTRY_PASSWORD=<ACR password>
45+
- CONTAINERREGISTRY_URL=acrffgithubci.azurecr.io
46+
- CONTAINERREGISTRY_USERNAME=acrffgithubci
47+
48+
## CI jobs
49+
50+
The integration test job deploys the application components using Docker-compose. Later on, it will be extended to run end-to-end test scenarios.
51+
52+
![Integration test job](integration-test-job.png)
53+
54+

docs/cicd/acr-password.png

100 KB
Loading

docs/cicd/create-secrets.png

225 KB
Loading

docs/cicd/deploy-acr.png

202 KB
Loading

docs/cicd/integration-test-job.png

112 KB
Loading

infra/docker-compose/docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ version: "3.7"
22

33
services:
44
core:
5+
build:
6+
context: ../..
7+
dockerfile: infra/docker/core/Dockerfile
58
image: ${FEAST_CORE_IMAGE}:${FEAST_VERSION}
69
volumes:
710
- ./core/${FEAST_CORE_CONFIG}:/etc/feast/application.yml
@@ -22,6 +25,9 @@ services:
2225
- --spring.config.location=classpath:/application.yml,file:/etc/feast/application.yaml
2326

2427
online-serving:
28+
build:
29+
context: ../..
30+
dockerfile: infra/docker/serving/Dockerfile
2531
image: ${FEAST_SERVING_IMAGE}:${FEAST_VERSION}
2632
volumes:
2733
- ./serving/${FEAST_ONLINE_SERVING_CONFIG}:/etc/feast/application.yml
@@ -39,6 +45,9 @@ services:
3945
- --spring.config.location=classpath:/application.yml,file:/etc/feast/application.yml
4046

4147
batch-serving:
48+
build:
49+
context: ../..
50+
dockerfile: infra/docker/serving/Dockerfile
4251
image: ${FEAST_SERVING_IMAGE}:${FEAST_VERSION}
4352
volumes:
4453
- ./serving/${FEAST_BATCH_SERVING_CONFIG}:/etc/feast/application.yml

infra/docker/ci/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@ RUN PROTOC_ZIP=protoc-${PROTOC_VERSION}-linux-x86_64.zip && \
4141
go get gopkg.in/russross/blackfriday.v2 && \
4242
git clone https://github.com/istio/tools/ && \
4343
cd tools/cmd/protoc-gen-docs && \
44-
go build && mkdir -p $HOME/bin && cp protoc-gen-docs $HOME/bin
44+
go build && mkdir -p $HOME/bin && cp protoc-gen-docs $HOME/bin
45+
46+
COPY Makefile /build/Makefile
47+
COPY sdk/python/requirements-ci.txt /build/sdk/python/requirements-ci.txt
48+
RUN cd /build && make install-python-ci-dependencies install-go-ci-dependencies && rm -rf /build

0 commit comments

Comments
 (0)