Skip to content

Commit

Permalink
Merge pull request #4 from dafyddj/feat/libbuild
Browse files Browse the repository at this point in the history
feat: move to using local reusable workflow `libbuild.yml`
  • Loading branch information
dafyddj authored Apr 23, 2024
2 parents a558307 + bb97371 commit 485abb7
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 0 deletions.
96 changes: 96 additions & 0 deletions template/.github/workflows/libbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Build boxes

on:
workflow_call:
inputs:
build-os-version:
required: true
type: string
description: The OS version to build (must match a value in the local file `os_vers`)
build-runner:
type: string
default: macos-12
build-type:
required: true
type: string
description: The VM system type to build (must match a value in the local file `builds`)
timeout-minutes:
type: number
default: 30
description: A timeout value in minutes for the whole job to complete
upload-box:
type: boolean
default: true

jobs:
run-packer:
name: Build & test box
runs-on: ${{ inputs.build-runner }}
timeout-minutes: ${{ inputs.timeout-minutes }}
env:
MAKE_VARS: ""
steps:
- name: Checkout repository
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- name: Debug on runner (When re-run with "Enable debug logging" checked)
if: runner.debug
uses: mxschmitt/action-tmate@a283f9441d2d96eb62436dc46d7014f5d357ac22 # v3
with:
detached: true
- name: Install virtualisation software
env:
TECHNEG_VAGRANT_PROVIDER: ${{ startsWith(inputs.build-type, 'qemu') && 'qemu-system-x86' || 'virtualbox' }}
if: ${{ !startsWith(runner.name, 'self') }}
run: |
kernel_name=$(uname -s)
if [ "$kernel_name" == "Linux" ]; then
sudo apt update
sudo apt --yes install vagrant $TECHNEG_VAGRANT_PROVIDER
elif [ "$kernel_name" == "Darwin" ]; then
brew update
brew install make
fi
- name: Prepare environment
if: startsWith(inputs.build-type, 'qemu')
run: |
kernel_name=$(uname -s)
if [ "$kernel_name" == "Linux" ]; then
echo PKR_VAR_accelerator=kvm >> $GITHUB_ENV
fi
- name: Run Packer
id: packer
env:
PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gmake ${{ env.MAKE_VARS }} -f ${{ inputs.build-type }}/Makefile ${{ inputs.build-os-version }}
- name: Prepare Vagrant
if: startsWith(inputs.build-type, 'qemu')
run: vagrant plugin install vagrant-qemu
- name: Install Test Kitchen
if: ${{ !startsWith(runner.name, 'self') }}
run: |
echo ::group::Installing Chef Workstation
kernel_name=$(uname -s)
if [ "$kernel_name" == "Linux" ]; then
wget --no-verbose https://packages.chef.io/files/stable/chef-workstation/23.7.1042/ubuntu/22.04/chef-workstation_23.7.1042-1_amd64.deb
sudo dpkg --install chef-workstation_23.7.1042-1_amd64.deb
elif [ "$kernel_name" == "Darwin" ]; then
sudo echo "Refresh sudo cached credential"
brew install chef-workstation
fi
echo ::endgroup::
chef -v
- name: Prepare Test Kitchen
if: startsWith(inputs.build-type, 'vbox')
run: echo TECHNEG_VAGRANT_PROVIDER=virtualbox >> $GITHUB_ENV
- name: Run Test Kitchen
env:
TECHNEG_VAGRANT_BOX: ${{ steps.packer.outputs.vagrant-box }}
run: kitchen test
- name: Upload to Vagrant Cloud (On GitHub default branch only)
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
env:
PACKER_COMMAND: ${{ inputs.upload-box && 'build -timestamp-ui' || 'validate' }}
VAGRANT_CLOUD_TOKEN: ${{ secrets.VAGRANT_CLOUD_TOKEN }}
run: |
packer $PACKER_COMMAND -only \*.${{ inputs.build-os-version }} -var version=$(bin/version) -var prefix= -var no_release=false -var box_dir=box/${{ inputs.build-type }} upload
2 changes: 2 additions & 0 deletions test/GenerateProject/catalogue.tt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ The following new files/directories were created:
----.copier-answers.yml
----.github
--------renovate.json5
--------workflows
------------libbuild.yml
----.gitignore
----.pre-commit-config.yaml
----bin
Expand Down
1 change: 1 addition & 0 deletions test/GenerateProject/libbuild_yml.tt
2 changes: 2 additions & 0 deletions test/SetBoxName/catalogue.tt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ The following new files/directories were created:
----.copier-answers.yml
----.github
--------renovate.json5
--------workflows
------------libbuild.yml
----.gitignore
----.pre-commit-config.yaml
----bin
Expand Down
96 changes: 96 additions & 0 deletions test/SetBoxName/libbuild_yml.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Build boxes

on:
workflow_call:
inputs:
build-os-version:
required: true
type: string
description: The OS version to build (must match a value in the local file `os_vers`)
build-runner:
type: string
default: macos-12
build-type:
required: true
type: string
description: The VM system type to build (must match a value in the local file `builds`)
timeout-minutes:
type: number
default: 30
description: A timeout value in minutes for the whole job to complete
upload-box:
type: boolean
default: true

jobs:
run-packer:
name: Build & test box
runs-on: ${{ inputs.build-runner }}
timeout-minutes: ${{ inputs.timeout-minutes }}
env:
MAKE_VARS: ""
steps:
- name: Checkout repository
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- name: Debug on runner (When re-run with "Enable debug logging" checked)
if: runner.debug
uses: mxschmitt/action-tmate@a283f9441d2d96eb62436dc46d7014f5d357ac22 # v3
with:
detached: true
- name: Install virtualisation software
env:
TECHNEG_VAGRANT_PROVIDER: ${{ startsWith(inputs.build-type, 'qemu') && 'qemu-system-x86' || 'virtualbox' }}
if: ${{ !startsWith(runner.name, 'self') }}
run: |
kernel_name=$(uname -s)
if [ "$kernel_name" == "Linux" ]; then
sudo apt update
sudo apt --yes install vagrant $TECHNEG_VAGRANT_PROVIDER
elif [ "$kernel_name" == "Darwin" ]; then
brew update
brew install make
fi
- name: Prepare environment
if: startsWith(inputs.build-type, 'qemu')
run: |
kernel_name=$(uname -s)
if [ "$kernel_name" == "Linux" ]; then
echo PKR_VAR_accelerator=kvm >> $GITHUB_ENV
fi
- name: Run Packer
id: packer
env:
PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gmake ${{ env.MAKE_VARS }} -f ${{ inputs.build-type }}/Makefile ${{ inputs.build-os-version }}
- name: Prepare Vagrant
if: startsWith(inputs.build-type, 'qemu')
run: vagrant plugin install vagrant-qemu
- name: Install Test Kitchen
if: ${{ !startsWith(runner.name, 'self') }}
run: |
echo ::group::Installing Chef Workstation
kernel_name=$(uname -s)
if [ "$kernel_name" == "Linux" ]; then
wget --no-verbose https://packages.chef.io/files/stable/chef-workstation/23.7.1042/ubuntu/22.04/chef-workstation_23.7.1042-1_amd64.deb
sudo dpkg --install chef-workstation_23.7.1042-1_amd64.deb
elif [ "$kernel_name" == "Darwin" ]; then
sudo echo "Refresh sudo cached credential"
brew install chef-workstation
fi
echo ::endgroup::
chef -v
- name: Prepare Test Kitchen
if: startsWith(inputs.build-type, 'vbox')
run: echo TECHNEG_VAGRANT_PROVIDER=virtualbox >> $GITHUB_ENV
- name: Run Test Kitchen
env:
TECHNEG_VAGRANT_BOX: ${{ steps.packer.outputs.vagrant-box }}
run: kitchen test
- name: Upload to Vagrant Cloud (On GitHub default branch only)
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
env:
PACKER_COMMAND: ${{ inputs.upload-box && 'build -timestamp-ui' || 'validate' }}
VAGRANT_CLOUD_TOKEN: ${{ secrets.VAGRANT_CLOUD_TOKEN }}
run: |
packer $PACKER_COMMAND -only \*.${{ inputs.build-os-version }} -var version=$(bin/version) -var prefix= -var no_release=false -var box_dir=box/${{ inputs.build-type }} upload
1 change: 1 addition & 0 deletions test/config.tt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ create_catalogues:true
[collate_file]
gitignore:.gitignore
kitchen_yml:kitchen.yml
libbuild_yml:.github/workflows/libbuild.yml
pre-commit_yaml:.pre-commit-config.yaml
post_mk:post.mk
pre_mk:pre.mk
Expand Down

0 comments on commit 485abb7

Please sign in to comment.