Skip to content

Commit 9fe8e81

Browse files
committed
Add shared matrix.json for actions
1 parent 700241e commit 9fe8e81

File tree

4 files changed

+62
-16
lines changed

4 files changed

+62
-16
lines changed

.github/workflows/build-utbot.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,25 @@ on:
55
branches: [main]
66

77
jobs:
8+
matrix-prep:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
matrix: ${{ steps.set-matrix.outputs.matrix }}
12+
steps:
13+
- name: Read config from matrix.json
14+
uses: actions/checkout@v2
15+
- id: set-matrix
16+
run: |
17+
TASKS=$(echo $(cat .github/workflows/matrix.json) | sed 's/ //g' )
18+
echo "::set-output name=matrix::$TASKS"
19+
820
build:
9-
runs-on: ubuntu-18.04
21+
needs: matrix-prep
22+
strategy:
23+
matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
24+
runs-on: ubuntu-${{ matrix.OPERATING_SYSTEM_TAG }}
1025
container:
11-
# It is impossible to parametrize image via workflow environment,
12-
# so its name is hard-coded.
13-
# https://github.com/actions/runner/issues/480
14-
image: ghcr.io/unittestbot/utbotcpp/base_env:24-11-2021
26+
image: ghcr.io/unittestbot/utbotcpp/base_env:${{ matrix.DOCKER_TAG }}
1527
credentials:
1628
username: ${{ github.actor }}
1729
password: ${{ secrets.GITHUB_TOKEN }}
@@ -20,7 +32,7 @@ jobs:
2032
UTBOT_INSTALL_DIR: /utbot_distr/install
2133
GRPC_PATH: /utbot_distr/install
2234
CLI_PATH: /utbot_distr/cli
23-
DOCKER_TAG: 24-11-2021
35+
DOCKER_TAG: ${{ matrix.DOCKER_TAG }}
2436
ARTIFACT_DIR: utbot-artifact
2537
steps:
2638
- name: Checkout repository

.github/workflows/matrix.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"include": [
3+
{
4+
"DOCKER_TAG": "24-11-2021",
5+
"OPERATING_SYSTEM_TAG": "18.04"
6+
}
7+
]
8+
}

.github/workflows/publish-base-env.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,25 @@ on:
55
env:
66
REGISTRY: ghcr.io
77
IMAGE_NAME: base_env
8-
TAG: 24-11-2021
98

109
jobs:
10+
matrix-prep:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
matrix: ${{ steps.set-matrix.outputs.matrix }}
14+
steps:
15+
- name: Read config from matrix.json
16+
uses: actions/checkout@v2
17+
- id: set-matrix
18+
run: |
19+
TASKS=$(echo $(cat .github/workflows/matrix.json) | sed 's/ //g' )
20+
echo "::set-output name=matrix::$TASKS"
21+
1122
build-docker:
12-
runs-on: ubuntu-18.04
23+
needs: matrix-prep
24+
strategy:
25+
matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
26+
runs-on: ubuntu-${{ matrix.OPERATING_SYSTEM_TAG }}
1327
permissions:
1428
contents: read
1529
packages: write
@@ -31,7 +45,7 @@ jobs:
3145
uses: actions/cache@v2
3246
with:
3347
path: /tmp/.buildx-cache
34-
key: ${{ runner.os }}-buildx-${{env.IMAGE_NAME}}-${{ env.TAG }}
48+
key: ${{ runner.os }}-buildx-${{env.IMAGE_NAME}}-${{ matrix.DOCKER_TAG }}
3549
restore-keys: |
3650
${{ runner.os }}-buildx-buildx
3751
@@ -41,7 +55,7 @@ jobs:
4155
with:
4256
images: ${{env.REGISTRY}}/${{github.repository}}/${{env.IMAGE_NAME}}
4357
tags: |
44-
type=raw,value=${{ env.TAG }}
58+
type=raw,value=${{ matrix.DOCKER_TAG }}
4559
4660
- name: Build and push image
4761
uses: docker/build-push-action@v2
@@ -55,7 +69,7 @@ jobs:
5569
cache-from: type=local,src=/tmp/.buildx-cache
5670
cache-to: type=local,dest=/tmp/.buildx-cache-new
5771
build-args: |
58-
OPERATING_SYSTEM_TAG=18.04
72+
OPERATING_SYSTEM_TAG=${{ matrix.OPERATING_SYSTEM_TAG }}
5973
# Temp fix
6074
# https://github.com/docker/build-push-action/issues/252
6175
# https://github.com/moby/buildkit/issues/1896

.github/workflows/publish-utbot.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,30 @@ on:
55
branches: [main]
66

77
jobs:
8+
matrix-prep:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
matrix: ${{ steps.set-matrix.outputs.matrix }}
12+
steps:
13+
- name: Read config from matrix.json
14+
uses: actions/checkout@v2
15+
- id: set-matrix
16+
run: |
17+
TASKS=$(echo $(cat .github/workflows/matrix.json) | sed 's/ //g' )
18+
echo "::set-output name=matrix::$TASKS"
19+
820
publish:
9-
runs-on: ubuntu-18.04
21+
needs: matrix-prep
22+
strategy:
23+
matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
24+
runs-on: ubuntu-${{ matrix.OPERATING_SYSTEM_TAG }}
1025
env:
1126
# Environment for the job and for the container is, sadly, duplicated
1227
# https://github.com/docker/compose/issues/1837
1328
VERSION: ${{ format('1.0.{0}', github.run_number) }}
1429
ARTIFACT_DIR: utbot-artifact
1530
container:
16-
# It is impossible to parametrize image via workflow environment,
17-
# so its name is hard-coded.
18-
# https://github.com/actions/runner/issues/480
19-
image: ghcr.io/unittestbot/utbotcpp/base_env:24-11-2021
31+
image: ghcr.io/unittestbot/utbotcpp/base_env:${{ matrix.DOCKER_TAG }}
2032
credentials:
2133
username: ${{ github.actor }}
2234
password: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)