|
| 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 |
0 commit comments