Skip to content

Commit

Permalink
Add shared matrix.json for actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ladisgin committed Nov 25, 2021
1 parent 2304ef5 commit 5a09e5b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 16 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/build-utbot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@ on:
branches: [main]

jobs:
matrix-prep:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- id: set-matrix
uses: JoshuaTheMiller/[email protected]
with:
inputFile: '.github/workflows/matrix.json'
filter: '[?runOnBranch==`${{ github.ref }}` || runOnBranch==`always`]'

build:
runs-on: ubuntu-18.04
needs: matrix-prep
strategy:
matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
runs-on: ubuntu-${{ matrix.OPERATING_SYSTEM_TAG }}
container:
# It is impossible to parametrize image via workflow environment,
# so its name is hard-coded.
# https://github.com/actions/runner/issues/480
image: ghcr.io/unittestbot/utbotcpp/base_env:24-11-2021
image: ghcr.io/unittestbot/utbotcpp/base_env:${{ matrix.DOCKER_TAG }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -20,7 +32,7 @@ jobs:
UTBOT_INSTALL_DIR: /utbot_distr/install
GRPC_PATH: /utbot_distr/install
CLI_PATH: /utbot_distr/cli
DOCKER_TAG: 24-11-2021
DOCKER_TAG: ${{ matrix.DOCKER_TAG }}
ARTIFACT_DIR: utbot-artifact
steps:
- name: Checkout repository
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"DOCKER_TAG": "24-11-2021",
"OPERATING_SYSTEM_TAG": "18.04"
}
24 changes: 19 additions & 5 deletions .github/workflows/publish-base-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,25 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: base_env
TAG: 24-11-2021

jobs:
matrix-prep:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- id: set-matrix
uses: JoshuaTheMiller/[email protected]
with:
inputFile: '.github/workflows/matrix.json'
filter: '[?runOnBranch==`${{ github.ref }}` || runOnBranch==`always`]'

build-docker:
runs-on: ubuntu-18.04
needs: matrix-prep
strategy:
matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
runs-on: ubuntu-${{ matrix.OPERATING_SYSTEM_TAG }}
permissions:
contents: read
packages: write
Expand All @@ -31,7 +45,7 @@ jobs:
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{env.IMAGE_NAME}}-${{ env.TAG }}
key: ${{ runner.os }}-buildx-${{env.IMAGE_NAME}}-${{ matrix.DOCKER_TAG }}
restore-keys: |
${{ runner.os }}-buildx-buildx
Expand All @@ -41,7 +55,7 @@ jobs:
with:
images: ${{env.REGISTRY}}/${{github.repository}}/${{env.IMAGE_NAME}}
tags: |
type=raw,value=${{ env.TAG }}
type=raw,value=${{ matrix.DOCKER_TAG }}
- name: Build and push image
uses: docker/build-push-action@v2
Expand All @@ -55,7 +69,7 @@ jobs:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
build-args: |
OPERATING_SYSTEM_TAG=18.04
OPERATING_SYSTEM_TAG=${{ matrix.OPERATING_SYSTEM_TAG }}
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
Expand Down
22 changes: 17 additions & 5 deletions .github/workflows/publish-utbot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,30 @@ on:
branches: [main]

jobs:
matrix-prep:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- id: set-matrix
uses: JoshuaTheMiller/[email protected]
with:
inputFile: '.github/workflows/matrix.json'
filter: '[?runOnBranch==`${{ github.ref }}` || runOnBranch==`always`]'

publish:
runs-on: ubuntu-18.04
needs: matrix-prep
strategy:
matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
runs-on: ubuntu-${{ matrix.OPERATING_SYSTEM_TAG }}
env:
# Environment for the job and for the container is, sadly, duplicated
# https://github.com/docker/compose/issues/1837
VERSION: ${{ format('1.0.{0}', github.run_number) }}
ARTIFACT_DIR: utbot-artifact
container:
# It is impossible to parametrize image via workflow environment,
# so its name is hard-coded.
# https://github.com/actions/runner/issues/480
image: ghcr.io/unittestbot/utbotcpp/base_env:24-11-2021
image: ghcr.io/unittestbot/utbotcpp/base_env:${{ matrix.DOCKER_TAG }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit 5a09e5b

Please sign in to comment.