-
Notifications
You must be signed in to change notification settings - Fork 5
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
Build and test images #14
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
829ad71
bin: Add script for building distro
MusicDin 9973902
.github/workflows: Build Debian image
MusicDin 2b7bbe3
bin: Add image test script
MusicDin 6af0c70
.github/workflwos: Add image-setup composite action
MusicDin bb13906
.github/workflows: Add image-test composite action
MusicDin 4b4d4c4
.github/workflows: Add main image workflow
MusicDin 148c207
.github/workflows: Add Alpine image build
MusicDin f04a5eb
.github/workflows: Add Ubuntu image build
MusicDin bacbfe8
.github/workflows: Add image-upload composite action
MusicDin 726e0eb
.github/workflows: Enable all alpine,debian, and ubuntu releases
MusicDin eb8e7c1
.github/workflows: Do not fail fast
MusicDin 09994a5
.github/workflows: Exclude some ubuntu combinations
MusicDin d38be30
.github/workflows: Add Fedora image build
MusicDin 13a9636
.github/workflows: Add CentOS image build
MusicDin 76b9002
.github/workflows: Add busybox image build
MusicDin 1aaaecf
tmp: Disable working images
MusicDin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Setup Environment | ||
description: Composite action that sets up the environment for building and testing images | ||
|
||
inputs: | ||
lxd-channel: | ||
description: LXD snap channel to install | ||
default: latest/edge | ||
go-version: | ||
description: Go version to install | ||
default: 1.22.x | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Install dependencies | ||
shell: bash | ||
run: | | ||
sudo apt-get -qq update | ||
sudo apt-get install -y --no-install-recommends \ | ||
debootstrap \ | ||
qemu-utils \ | ||
git \ | ||
gpg \ | ||
rsync \ | ||
squashfs-tools | ||
|
||
- name: Setup LXD ${{ inputs.lxd-channel }} | ||
shell: bash | ||
run: | | ||
sudo snap refresh lxd --channel=${{ inputs.lxd-channel }} | ||
sudo lxd waitready --timeout 60 | ||
sudo chmod 777 /var/snap/lxd/common/lxd/unix.socket | ||
sudo lxd init --auto | ||
lxc version | ||
|
||
- name: Install Go ${{ inputs.go-version }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "${{ inputs.go-version }}" | ||
|
||
- name: Build LXD imagebuilder | ||
shell: bash | ||
run: make | ||
|
||
- name: Clone LXD CI repository (for image recipes) | ||
shell: bash | ||
run: git clone https://github.com/musicdin/lxd-ci --branch cp/images2 --depth 1 | ||
|
||
- name: Print supported driver | ||
shell: bash | ||
run: | | ||
lxc query /1.0 | jq '.environment.driver' | ||
sudo lxc query /1.0 | jq '.environment.driver' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Test Image | ||
description: Composite action that test built image | ||
|
||
inputs: | ||
target: | ||
description: Directory where built image is located | ||
required: true | ||
distro: | ||
description: Image distribution | ||
required: true | ||
release: | ||
description: Image release | ||
required: true | ||
variant: | ||
description: Image variant | ||
required: true | ||
type: | ||
description: Image type [container, vm] | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Test image | ||
shell: bash | ||
run: | | ||
TYPE=${{ inputs.type }} | ||
TARGET=${{ inputs.target }} | ||
DISTRO=${{ inputs.distro }} | ||
RELEASE=${{ inputs.release }} | ||
VARIANT=${{ inputs.variant }} | ||
|
||
set -e | ||
|
||
TEST_ID="${DISTRO}-${RELEASE}-${VARIANT} (${TYPE})" | ||
echo "==> TEST: ${TEST_ID}" | ||
|
||
VIRT_ENABLED=$(lxc query /1.0 | jq '.environment.driver | contains("qemu")') | ||
if [ ${TYPE} = "vm" ] && [ "${VIRT_ENABLED}" != "true" ]; then | ||
echo "==> SKIP: Virtualization is not supported" | ||
exit 0 | ||
fi | ||
|
||
./bin/test-image "${TYPE}" "${DISTRO}" "${RELEASE}" "${VARIANT}" "${TARGET}" | ||
|
||
if [ "$?" = "0" ]; then | ||
echo "==> PASS: ${TEST_ID}" | ||
exit 0 | ||
fi | ||
|
||
echo "==> FAIL: ${TEST_ID}" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Upload Image | ||
description: Composite action for uploading built images | ||
|
||
inputs: | ||
name: | ||
description: Final image name | ||
required: true | ||
target: | ||
description: Directory where built image is located | ||
required: true | ||
# types: | ||
# description: Image types | ||
# required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
# actions/upload-artifact does not expand env vars. | ||
- name: Expand target path | ||
shell: bash | ||
run: echo "target=${{ inputs.target }}" >> $GITHUB_ENV | ||
|
||
- name: Print artifacts | ||
shell: bash | ||
run: ls -lah "${{ env.target }}" | ||
|
||
# - name: Make tarball | ||
# id: tarball | ||
# shell: bash | ||
# run: | | ||
# files=$(cd ${{ inputs.target }} && ls *.tar.xz *.qcow2 *.squashfs image.yaml serial 2> /dev/null) | ||
# tar -czvf "${{ inputs.name }}.tar.gz" -C ${{ inputs.target }} ${files} | ||
|
||
- name: Publish artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: "${{ inputs.name }}" | ||
# path: "${{ inputs.name }}.tar.gz" | ||
path: | | ||
${{ env.target }}/*.qcow2 | ||
${{ env.target }}/*.squashfs | ||
${{ env.target }}/*.tar.xz | ||
${{ env.target }}/image.yaml | ||
${{ env.target }}/serial | ||
if-no-files-found: "error" | ||
retention-days: 1 | ||
compression-level: 0 | ||
overwrite: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: Build Alpine Images | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_call: | ||
inputs: | ||
publish: | ||
type: boolean | ||
default: false | ||
description: Publish built image | ||
|
||
jobs: | ||
alpine: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
release: | ||
- "3.16" | ||
- "3.17" | ||
- "3.18" | ||
- "3.19" | ||
- "edge" | ||
architecture: | ||
- amd64 | ||
# - arm64 | ||
variant: | ||
- default | ||
- cloud | ||
env: | ||
type: "container" | ||
distro: "${{ github.job }}" | ||
target: "${HOME}/build" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup environment | ||
uses: ./.github/actions/image-setup | ||
|
||
- name: Determine image types | ||
run: | | ||
ARCH="${{ matrix.architecture }}" | ||
if [ "${ARCH}" = "amd64" ] || [ "${ARCH}" = "arm64" ]; then | ||
echo "type=container,vm" >> $GITHUB_ENV | ||
fi | ||
|
||
- name: Build image | ||
run: | | ||
TIMEOUT=1800 | ||
YAML="${{ github.workspace }}/lxd-ci/images/${{ env.distro }}.yaml" | ||
ARCH="${{ matrix.architecture }}" | ||
TYPE="${{ env.type }}" | ||
|
||
IMAGE_ARCH="${ARCH}" | ||
[ "${ARCH}" = "amd64" ] && IMAGE_ARCH="x86_64" | ||
[ "${ARCH}" = "arm64" ] && IMAGE_ARCH="aarch64" | ||
|
||
./bin/build-distro "${YAML}" "${ARCH}" "${TYPE}" "${TIMEOUT}" "${{ env.target }}" \ | ||
-o image.architecture="${IMAGE_ARCH}" \ | ||
-o image.release=${{ matrix.release }} \ | ||
-o image.variant=${{ matrix.variant }} | ||
|
||
- name: Print build artifacts | ||
run: ls -lah "${{ env.target }}" | ||
|
||
- name: Test container image | ||
uses: ./.github/actions/image-test | ||
if: contains(env.type, 'container') | ||
with: | ||
type: container | ||
target: ${{ env.target }} | ||
distro: ${{ env.distro }} | ||
release: ${{ matrix.release }} | ||
variant: ${{ matrix.variant }} | ||
|
||
- name: Test VM image | ||
uses: ./.github/actions/image-test | ||
if: contains(env.type, 'vm') | ||
with: | ||
type: vm | ||
target: ${{ env.target }} | ||
distro: ${{ env.distro }} | ||
release: ${{ matrix.release }} | ||
variant: ${{ matrix.variant }} | ||
|
||
- name: Upload image | ||
uses: ./.github/actions/image-upload | ||
if: inputs.publish == true | ||
with: | ||
name: "${{ env.distro }}-${{ matrix.release }}-${{ matrix.architecture }}-${{ matrix.variant }}" | ||
target: ${{ env.target }} | ||
# types: ${{ env.type }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Build BusyBox Images | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_call: | ||
inputs: | ||
publish: | ||
type: boolean | ||
default: false | ||
description: Publish built image | ||
|
||
jobs: | ||
busybox: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
release: | ||
- 1.36.1 | ||
architecture: | ||
- amd64 | ||
# - arm64 | ||
variant: | ||
- default | ||
env: | ||
type: "container" | ||
distro: "${{ github.job }}" | ||
target: "${HOME}/build" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup environment | ||
uses: ./.github/actions/image-setup | ||
|
||
- name: Build image | ||
run: | | ||
TIMEOUT=1800 | ||
YAML="${{ github.workspace }}/lxd-ci/images/${{ env.distro }}.yaml" | ||
ARCH="${{ matrix.architecture }}" | ||
TYPE="${{ env.type }}" | ||
|
||
./bin/build-distro "${YAML}" "${ARCH}" "${TYPE}" "${TIMEOUT}" "${{ env.target }}" \ | ||
-o image.architecture="${IMAGE_ARCH}" \ | ||
-o image.release=${{ matrix.release }} \ | ||
-o image.variant=${{ matrix.variant }} \ | ||
${EXTRA_ARGS} | ||
|
||
- name: Print build artifacts | ||
run: ls -lah "${{ env.target }}" | ||
|
||
- name: Test container image | ||
uses: ./.github/actions/image-test | ||
if: contains(env.type, 'container') | ||
with: | ||
type: container | ||
target: ${{ env.target }} | ||
distro: ${{ env.distro }} | ||
release: ${{ matrix.release }} | ||
variant: ${{ matrix.variant }} | ||
|
||
- name: Test VM image | ||
uses: ./.github/actions/image-test | ||
if: contains(env.type, 'vm') | ||
with: | ||
type: vm | ||
target: ${{ env.target }} | ||
distro: ${{ env.distro }} | ||
release: ${{ matrix.release }} | ||
variant: ${{ matrix.variant }} | ||
|
||
- name: Upload image | ||
uses: ./.github/actions/image-upload | ||
if: inputs.publish == true | ||
with: | ||
name: "${{ env.distro }}-${{ matrix.release }}-${{ matrix.architecture }}-${{ matrix.variant }}" | ||
target: ${{ env.target }} | ||
# types: ${{ env.type }} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace all those by a single top section:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried this one, but composite actions do not support
default.run.shell
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh bummer. Have you tried putting it in the top composite job?