Skip to content

Commit

Permalink
ci: Only start a single container job
Browse files Browse the repository at this point in the history
This introduces the main.yml workflow which is triggered on push and
pull requests which then calls out to the workflows we actually want to
run. The first one is container.yml which is a dependency of both
build-and-test.yml and pages.yml which run in parallel.

This means that we only have to check the registry once for the image
and if we have to build it, we also do it once only.
  • Loading branch information
swick committed Oct 10, 2024
1 parent c32d4e3 commit 8f0fe4f
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 32 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
name: Build and Test

on: [push, pull_request]

env:
TESTS_TIMEOUT: 10 # in minutes

jobs:
build-container:
uses: ./.github/workflows/container.yml
permissions:
packages: write
on:
workflow_call:
inputs:
image:
required: true
type: string
image_options:
required: true
type: string

jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
needs: build-container
strategy:
matrix:
compiler: ['gcc', 'clang']
sanitizer: ['address']

container:
image: ${{ needs.build-container.outputs.image }}
image: ${{ inputs.image }}
env:
CFLAGS: -Wp,-D_FORTIFY_SOURCE=2
CC: ${{ matrix.compiler }}
TEST_IN_CI: 1
G_MESSAGES_DEBUG: all
options: ${{ needs.build-container.outputs.image_options }}
options: ${{ inputs.image_options }}

steps:
- name: Configure environment
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
name: Create build container

env:
IMAGE_TAG: 20241008-1

Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on: [push, pull_request]

jobs:
build-container:
name: Container
uses: ./.github/workflows/container.yml
permissions:
packages: write

build-and-test:
name: Build and Test
uses: ./.github/workflows/build-and-test.yml
needs: build-container
with:
image: ${{ needs.build-container.outputs.image }}
image_options: ${{ needs.build-container.outputs.image_options }}

pages:
name: Documentation & Website
uses: ./.github/workflows/pages.yml
needs: build-container
permissions:
contents: read
pages: write
id-token: write
with:
image: ${{ needs.build-container.outputs.image }}
image_options: ${{ needs.build-container.outputs.image_options }}
31 changes: 13 additions & 18 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
name: Documentation & Website

on: [push, pull_request]

permissions:
contents: read
pages: write
id-token: write
on:
workflow_call:
inputs:
image:
required: true
type: string
image_options:
required: true
type: string

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build-container:
uses: ./.github/workflows/container.yml
permissions:
packages: write

build:
name: Build docs and website
runs-on: ubuntu-latest
needs: build-container
permissions:
contents: write

container:
image: ${{ needs.build-container.outputs.image }}
options: ${{ needs.build-container.outputs.image_options }}
image: ${{ inputs.image }}
options: ${{ inputs.image_options }}

steps:
- name: Check out xdg-desktop-portal
Expand All @@ -52,6 +46,7 @@ jobs:

# Deployment job
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
environment:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:

jobs:
build-container:
name: Container
uses: ./.github/workflows/container.yml
permissions:
packages: write
Expand Down

0 comments on commit 8f0fe4f

Please sign in to comment.