Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shared matrix.json for actions #11

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
- name: Read config from matrix.json
uses: actions/checkout@v2
- id: set-matrix
run: |
TASKS=$(echo $(cat .github/workflows/matrix.json) | sed 's/ //g' )
echo "::set-output name=matrix::$TASKS"

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
8 changes: 8 additions & 0 deletions .github/workflows/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"include": [
{
"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:
- name: Read config from matrix.json
uses: actions/checkout@v2
- id: set-matrix
run: |
TASKS=$(echo $(cat .github/workflows/matrix.json) | sed 's/ //g' )
echo "::set-output name=matrix::$TASKS"

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:
- name: Read config from matrix.json
uses: actions/checkout@v2
- id: set-matrix
run: |
TASKS=$(echo $(cat .github/workflows/matrix.json) | sed 's/ //g' )
echo "::set-output name=matrix::$TASKS"

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