Skip to content

Build and test service #2091

Build and test service

Build and test service #2091

Workflow file for this run

---
name: "Build and test service"
on:
push:
branches:
- main
- 'releases/**'
paths:
# Build workflow changes
- '.github/workflows/build-service.yml'
- '.github/workflows/_matrix-gen.yaml'
- '.github/actions/**'
- 'Dockerfile'
- 'init-output-run/Dockerfile'
# Code (deployment ID) changes
- 'bin.src/write_init_outputs.py'
- 'config/**'
- 'pipelines/**'
- 'python/activator/**'
- 'python/initializer/**'
- 'python/shared/**'
# Need to re-test
- 'python/tester/utils.py'
- 'tests/**'
pull_request:
paths:
# Build workflow changes
- '.github/workflows/build-service.yml'
- '.github/workflows/_matrix-gen.yaml'
- '.github/actions/**'
- 'Dockerfile'
- 'init-output-run/Dockerfile'
# Code (deployment ID) changes
- 'bin.src/write_init_outputs.py'
- 'config/**'
- 'pipelines/**'
- 'python/activator/**'
- 'python/initializer/**'
- 'python/shared/**'
# Need to re-test
- 'python/tester/utils.py'
- 'tests/**'
workflow_dispatch:
permissions:
packages: write
env:
SERVICE_IMAGE_NAME: prompt-service
INIT_IMAGE_NAME: prompt-init
INIT_DOCKERDIR: init-output-run
BASE_IMAGE: ghcr.io/${{ github.repository_owner }}/prompt-base
jobs:
matrix-gen:
uses: ./.github/workflows/_matrix-gen.yaml
# Do testing and building in separate jobs to keep total disk usage down
test-service:
needs: matrix-gen
strategy:
matrix:
baseTag: ${{ fromJSON(needs.matrix-gen.outputs.matrix) }}
name: Test service
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: "Test service against ${{ env.BASE_IMAGE }}:${{ matrix.baseTag }}"
uses: ./.github/actions/test-service
with:
baseImage: ${{ env.BASE_IMAGE }}
baseTag: ${{ matrix.baseTag }}
ghcr_user: ${{ github.actor }}
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
update-service-image:
name: Update service image
needs:
- matrix-gen
- test-service
runs-on: ubuntu-latest
strategy:
matrix:
baseTag: ${{ fromJSON(needs.matrix-gen.outputs.matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build and push image
uses: ./.github/actions/update-dev-image
with:
imageName: ${{ env.SERVICE_IMAGE_NAME }}
baseImage: ${{ env.BASE_IMAGE }}
baseTag: ${{ matrix.baseTag }}
ghcr_user: ${{ github.actor }}
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
update-init-image:
name: Update init image
needs:
- matrix-gen
- test-service
runs-on: ubuntu-latest
strategy:
matrix:
baseTag: ${{ fromJSON(needs.matrix-gen.outputs.matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build and push image
uses: ./.github/actions/update-dev-image
with:
imageName: ${{ env.INIT_IMAGE_NAME }}
dockerDir: ${{ env.INIT_DOCKERDIR }}
baseImage: ${{ env.BASE_IMAGE }}
baseTag: ${{ matrix.baseTag }}
ghcr_user: ${{ github.actor }}
ghcr_token: ${{ secrets.GITHUB_TOKEN }}