Skip to content

Commit

Permalink
Update workflows
Browse files Browse the repository at this point in the history
Build and push toolkit and os flavor before build-iso and build-disk.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
  • Loading branch information
frelon committed Feb 8, 2024
1 parent f3d8258 commit 8227dbe
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 25 deletions.
68 changes: 44 additions & 24 deletions .github/workflows/build_and_test_x86.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,42 @@ concurrency:
cancel-in-progress: true

jobs:
# detect step checks what machines the later steps should run on
detect:
build-os:
permissions:
packages: write
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.detect.outputs.tests }}
env:
FLAVOR: ${{ inputs.flavor }}
ARCH: x86_64
TOOLKIT_REPO: ghcr.io/${{ github.repository }}/elemental-cli
REPO: ghcr.io/${{ github.repository }}/elemental-${{ inputs.flavor }}
steps:
- id: detect
env:
FLAVOR: ${{ inputs.flavor }}
- uses: actions/checkout@v4
- run: |
git fetch --prune --unshallow
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build toolkit
run: |
if [ "${FLAVOR}" == green ]; then
echo "tests=['test-upgrade', 'test-recovery', 'test-fallback', 'test-fsck', 'test-grubfallback']" >> $GITHUB_OUTPUT
else
echo "tests=['test-active']" >> $GITHUB_OUTPUT
fi
make pull-toolkit
make ARCH=${{ env.ARCH }} DOCKER_ARGS=--load build-os
make ARCH=${{ env.ARCH }} DOCKER_ARGS=--push build-os
build-iso:
needs: detect
needs:
- build-os
runs-on: ubuntu-latest
env:
FLAVOR: ${{ inputs.flavor }}
ARCH: x86_64
TOOLKIT_REPO: ghcr.io/${{github.repository}}/elemental-cli
REPO: ghcr.io/${{ github.repository }}/elemental-${{ inputs.flavor }}
steps:
- uses: actions/checkout@v4
- run: |
Expand All @@ -49,10 +62,6 @@ jobs:
with:
path: /tmp/*.iso
key: ${{ env.cache-name }}-${{ hashFiles('Dockerfile', '**/go.sum', '**/pkg/**', '**/examples/**', '**/cmd/**', '**/vendor/**', '**/Makefile', '**/main.go') }}
- if: ${{ steps.cache-iso.outputs.cache-hit != 'true' }}
name: Build toolkit
run: |
make build
- if: ${{ steps.cache-iso.outputs.cache-hit != 'true' }}
name: Build ISO
run: |
Expand All @@ -70,7 +79,8 @@ jobs:
enableCrossOsArchive: true

build-disk:
needs: detect
needs:
- build-os
runs-on: ubuntu-latest
env:
FLAVOR: ${{ inputs.flavor }}
Expand All @@ -95,15 +105,10 @@ jobs:
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
sudo df -h
- if: ${{ steps.cache-check.outputs.cache-hit != 'true' }}
name: Build toolkit
run: |
make build
- if: ${{ steps.cache-check.outputs.cache-hit != 'true' }}
name: Install to disk
run: |
sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-utils coreutils
make ARCH=${{ env.ARCH }} build-os
sudo -E make ARCH=${{ env.ARCH }} build-disk
sudo mv build/elemental-${{ env.FLAVOR }}.${{ env.ARCH}}.qcow2 /tmp/
- if: ${{ steps.cache-check.outputs.cache-hit != 'true' }}
Expand All @@ -117,6 +122,21 @@ jobs:
key: ${{ env.cache-name }}-${{ hashFiles('Dockerfile', '**/go.sum', '**/pkg/**', '**/examples/**', '**/cmd/**', '**/vendor/**', '**/Makefile', '**/main.go') }}
enableCrossOsArchive: true

detect:
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.detect.outputs.tests }}
steps:
- id: detect
env:
FLAVOR: ${{ inputs.flavor }}
run: |
if [ "${FLAVOR}" == green ]; then
echo "tests=['test-upgrade', 'test-recovery', 'test-fallback', 'test-fsck', 'test-grubfallback']" >> $GITHUB_OUTPUT
else
echo "tests=['test-active']" >> $GITHUB_OUTPUT
fi
tests-matrix:
needs:
- build-disk
Expand Down
26 changes: 25 additions & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,32 @@ jobs:
echo "flavor=['green']" >> $GITHUB_OUTPUT
fi
build-toolkit:
permissions:
packages: write
runs-on: ubuntu-latest
env:
ARCH: x86_64
TOOLKIT_REPO: ghcr.io/${{github.repository}}/elemental-cli
steps:
- uses: actions/checkout@v4
- run: |
git fetch --prune --unshallow
- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build toolkit
run: |
make DOCKER_ARGS=--load build
make DOCKER_ARGS=--push build
build-matrix:
needs: detect
needs:
- detect
- build-toolkit
strategy:
matrix:
flavor: ${{fromJson(needs.detect.outputs.flavor)}}
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ build:
push-toolkit:
$(DOCKER) push $(TOOLKIT_REPO):$(VERSION)

.PHONY: pull-toolkit
pull-toolkit:
$(DOCKER) pull $(TOOLKIT_REPO):$(VERSION)

.PHONY: build-cli
build-cli:
go build -ldflags '$(LDFLAGS)' -o build/elemental
Expand Down

0 comments on commit 8227dbe

Please sign in to comment.