Skip to content

Commit

Permalink
.github/workflows: changed versions to channels and other corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestl committed Nov 21, 2024
1 parent 6de88f7 commit 5560ca0
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 69 deletions.
58 changes: 0 additions & 58 deletions .github/workflows/determine-go-versions.yaml

This file was deleted.

60 changes: 60 additions & 0 deletions .github/workflows/go-channels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Determine Go snap channels

on:
workflow_call:
inputs:
include-snapd-build-go-channel:
description: 'Flag instructing to lookup the channel of Go snap used to build Snapd'
required: false
type: boolean
include-latest-go-channel:
description: 'Flag instructing to lookup the latest channel of Go snap'
required: false
type: boolean
specific-go-channels:
description: 'Space seperated list of required channels'
required: false
type: string
outputs:
go-channels:
description: 'JSON list of Go snap channels to use to populate the gochannel matrix'
value: ${{ jobs.determine.outputs.go-channels }}

jobs:
determine:
runs-on: ubuntu-latest
outputs:
go-channels: ${{ steps.determine.outputs.go-channels }}
steps:
- name: Determine Go snap channels
id: determine
run: |
# Initialize an empty list
GO_CHANNELS=()
# Optionally add specific channels
if [ -n "${{ inputs.specific-go-channels }}" ]; then
for CHANNEL in ${{ inputs.specific-go-channels }}; do
GO_CHANNELS+=("$CHANNEL")
done
fi
# Optionally add channel that snapd is build with
if [ "${{ inputs.include-snapd-build-go-channel }}" = "true" ]; then
# Simulate fetching the Snapd Go build channel (replace with actual logic)
BUILD_CHANNEL="1.18"
GO_CHANNELS+=("$BUILD_CHANNEL")
fi
# Optionally add latest channel
if [ "${{ inputs.include-latest-go-channel }}" = "true" ]; then
# Simulate fetching the latest Go channel (replace with actual logic)
LATEST_CHANNEL="1.23"
GO_CHANNELS+=("$LATEST_CHANNEL")
fi
# Remove duplicates and convert to JSON array
UNIQUE_CHANNELS=$(printf '%s\n' "${GO_CHANNELS[@]}" | sort -u | jq -R . | jq -s .)
# Output the list
echo "::set-output name=go-channels::$UNIQUE_CHANNELS"
29 changes: 18 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ concurrency:
cancel-in-progress: true

jobs:
required-go-versions:
uses: ./.github/workflows/determine-go-versions.yaml
required-go-channels:
uses: ./.github/workflows/go-channels.yaml
with:
# If build-version and latest version is the same,
# If build-channel and latest channel is the same,
# the duplicate will be removed
include-snapd-build-go-version: true
include-latest-go-version: true
include-snapd-build-go-channel: true
include-latest-go-channel: true

log-required-go-channels:
needs: required-go-channels
runs-on: ubuntu-latest
steps:
- name: Log Required Go Channels
run: echo "Required Go Channels: ${{ needs.required-go-channels.outputs.go-channels }}"

snap-builds:
uses: ./.github/workflows/snap-builds.yaml
Expand Down Expand Up @@ -90,7 +97,7 @@ jobs:
static-checks:
uses: ./.github/workflows/static-checks.yaml
needs:
- required-go-versions
- required-go-channels
- cache-build-deps
with:
runs-on: ubuntu-latest
Expand All @@ -100,7 +107,7 @@ jobs:
# we cache successful runs so it's fine to keep going
fail-fast: false
matrix:
gochannel: ${{ fromJson(needs.determine-go-versions.outputs.go-versions) }}
gochannel: ${{ fromJson(needs.required-go-channels.outputs.go-channels) }}

branch-static-checks:
runs-on: ubuntu-latest
Expand All @@ -126,7 +133,7 @@ jobs:
unit-tests:
uses: ./.github/workflows/unit-tests.yaml
needs:
- required-go-versions
- required-go-channels
- static-checks
with:
runs-on: ubuntu-22.04
Expand All @@ -136,15 +143,15 @@ jobs:
# we cache successful runs so it's fine to keep going
fail-fast: false
matrix:
gochannel: ${{ fromJson(needs.determine-go-versions.outputs.go-versions) }}
gochannel: ${{ fromJson(needs.required-go-channels.outputs.go-channels) }}
unit-scenario:
- normal

# TODO run unit tests of C code
unit-tests-special:
uses: ./.github/workflows/unit-tests.yaml
needs:
- required-go-versions
- required-go-channels
- static-checks
with:
runs-on: ubuntu-22.04
Expand All @@ -154,7 +161,7 @@ jobs:
# we cache successful runs so it's fine to keep going
fail-fast: false
matrix:
gochannel: ${{ fromJson(needs.determine-go-versions.outputs.go-versions) }}
gochannel: ${{ fromJson(needs.required-go-channels.outputs.go-channels) }}
unit-scenario:
- snapd_debug
- withbootassetstesting
Expand Down

0 comments on commit 5560ca0

Please sign in to comment.