-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: add basic packaging workflows (#4)
* Initial harness around building OpenWRT package * ci: add openwrt toolchain caching workflow * Makefile: add target to save package artifacts * ci: add combined workflow to build package and cache * ci: refactor combined workflow variable passing * ci: yet another variable passing refactoring * ci: add package building step * ci: upload package as build artifact * ci: use dynamic versioning * ci: adjust before merging
- Loading branch information
Showing
7 changed files
with
408 additions
and
4 deletions.
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,132 @@ | ||
name: build package | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
inputs: | ||
openwrt_version: | ||
description: "OpenWrt version" | ||
type: string | ||
required: true | ||
default: "23.05.3" | ||
openwrt_arch: | ||
description: "OpenWrt arch" | ||
type: string | ||
required: true | ||
default: "mips_24kc" | ||
openwrt_target: | ||
description: "OpenWrt target" | ||
type: string | ||
required: true | ||
default: "ath79" | ||
openwrt_subtarget: | ||
description: "OpenWrt subtarget" | ||
type: string | ||
required: true | ||
default: "generic" | ||
openwrt_vermagic: | ||
description: "OpenWrt vermagic" | ||
type: string | ||
required: true | ||
default: "auto" | ||
|
||
jobs: | ||
build: | ||
name: "v${{ matrix.build_env.tag }} - ${{ matrix.build_env.pkgarch }} :: ${{ matrix.build_env.target }}/${{ matrix.build_env.subtarget }} openwrt build" | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
build_env: | ||
- tag: ${{ inputs.openwrt_version || vars.DEFAULT_OPENWRT_VERSION }} | ||
pkgarch: ${{ inputs.openwrt_arch || vars.DEFAULT_OPENWRT_ARCH }} | ||
target: ${{ inputs.openwrt_target || vars.DEFAULT_OPENWRT_TARGET }} | ||
subtarget: ${{ inputs.openwrt_subtarget || vars.DEFAULT_OPENWRT_SUBTARGET }} | ||
vermagic: ${{ inputs.openwrt_vermagic || vars.DEFAULT_OPENWRT_VERMAGIC }} | ||
|
||
env: | ||
OPENWRT_RELEASE: ${{ matrix.build_env.tag }} | ||
OPENWRT_ARCH: ${{ matrix.build_env.pkgarch }} | ||
OPENWRT_TARGET: ${{ matrix.build_env.target }} | ||
OPENWRT_SUBTARGET: ${{ matrix.build_env.subtarget }} | ||
OPENWRT_VERMAGIC: ${{ matrix.build_env.vermagic }} | ||
|
||
steps: | ||
- name: checkout openwrt-loki-exporter | ||
uses: actions/checkout@v4 | ||
with: | ||
path: openwrt-loki-exporter | ||
fetch-depth: 0 | ||
|
||
- name: checkout openwrt | ||
uses: actions/checkout@v4 | ||
with: | ||
path: openwrt | ||
repository: openwrt/openwrt | ||
ref: v${{ matrix.build_env.tag }} | ||
fetch-depth: 0 | ||
|
||
- name: restore cached toolchain | ||
id: restore-toolchain-cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
fail-on-cache-miss: false | ||
key: ${{ runner.os }}-openwrt-cache-toolchain-${{ matrix.build_env.tag }}-${{ matrix.build_env.pkgarch }}-${{ matrix.build_env.target }}-${{ matrix.build_env.subtarget }} | ||
restore-keys: | | ||
${{ runner.os }}-openwrt-cache-toolchain-${{ matrix.build_env.pkgarch }}- | ||
path: | | ||
openwrt/.config | ||
openwrt/.config.old | ||
openwrt/feeds.conf | ||
openwrt/bin/** | ||
openwrt/build_dir/** | ||
openwrt/dl/** | ||
openwrt/feeds/** | ||
openwrt/package/** | ||
openwrt/staging_dir/** | ||
openwrt/tmp/** | ||
- name: building openwrt toolchain | ||
if: steps.restore-toolchain-cache.outputs.cache-hit != 'true' | ||
id: build-toolchain | ||
run: | | ||
set -x | ||
cd openwrt-loki-exporter | ||
make show-env | ||
time -p make build-toolchain | ||
make purge-circular-symlinks | ||
- name: save toolchain cache | ||
if: steps.restore-toolchain-cache.outputs.cache-hit != 'true' | ||
id: save-toolchain-cache | ||
uses: actions/cache/save@v4 | ||
with: | ||
key: ${{ runner.os }}-openwrt-cache-toolchain-${{ matrix.build_env.tag }}-${{ matrix.build_env.pkgarch }}-${{ matrix.build_env.target }}-${{ matrix.build_env.subtarget }} | ||
path: | | ||
openwrt/.config | ||
openwrt/.config.old | ||
openwrt/feeds.conf | ||
openwrt/bin/** | ||
openwrt/build_dir/** | ||
openwrt/dl/** | ||
openwrt/feeds/** | ||
openwrt/package/** | ||
openwrt/staging_dir/** | ||
openwrt/tmp/** | ||
- name: build package | ||
id: build-package | ||
run: | | ||
set -x | ||
cd openwrt-loki-exporter | ||
make show-env | ||
make export-env >> $GITHUB_OUTPUT | ||
time -p make package | ||
make prepare-artifacts | ||
- name: upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: loki-exporter-${{ steps.build-package.outputs.version_str }}_v${{ matrix.build_env.tag }}_${{ matrix.build_env.pkgarch }}_${{ matrix.build_env.target }}_${{ matrix.build_env.subtarget }} | ||
path: loki_exporter_artifacts/* |
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,91 @@ | ||
name: build toolchain cache | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
openwrt_version: | ||
description: "OpenWrt version" | ||
type: string | ||
required: true | ||
default: "23.05.3" | ||
openwrt_arch: | ||
description: "OpenWrt arch" | ||
type: string | ||
required: true | ||
default: "mips_24kc" | ||
openwrt_target: | ||
description: "OpenWrt target" | ||
type: string | ||
required: true | ||
default: "ath79" | ||
openwrt_subtarget: | ||
description: "OpenWrt subtarget" | ||
type: string | ||
required: true | ||
default: "generic" | ||
openwrt_vermagic: | ||
description: "OpenWrt vermagic" | ||
type: string | ||
required: true | ||
default: "auto" | ||
|
||
jobs: | ||
build: | ||
name: "v${{ matrix.build_env.tag }} - ${{ matrix.build_env.pkgarch }} :: ${{ matrix.build_env.target }}/${{ matrix.build_env.subtarget }} openwrt build" | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
build_env: | ||
- tag: ${{ inputs.openwrt_version }} | ||
pkgarch: ${{ inputs.openwrt_arch }} | ||
target: ${{ inputs.openwrt_target }} | ||
subtarget: ${{ inputs.openwrt_subtarget }} | ||
vermagic: ${{ inputs.openwrt_vermagic }} | ||
|
||
env: | ||
OPENWRT_RELEASE: ${{ matrix.build_env.tag }} | ||
OPENWRT_ARCH: ${{ matrix.build_env.pkgarch }} | ||
OPENWRT_TARGET: ${{ matrix.build_env.target }} | ||
OPENWRT_SUBTARGET: ${{ matrix.build_env.subtarget }} | ||
OPENWRT_VERMAGIC: ${{ matrix.build_env.vermagic }} | ||
|
||
steps: | ||
- name: checkout openwrt-loki-exporter | ||
uses: actions/checkout@v4 | ||
with: | ||
path: openwrt-loki-exporter | ||
fetch-depth: 0 | ||
|
||
- name: checkout openwrt | ||
uses: actions/checkout@v4 | ||
with: | ||
path: openwrt | ||
repository: openwrt/openwrt | ||
ref: v${{ matrix.build_env.tag }} | ||
fetch-depth: 0 | ||
|
||
- name: building openwrt toolchain | ||
id: build-toolchain | ||
run: | | ||
set -x | ||
cd openwrt-loki-exporter | ||
make show-env | ||
time -p make build-toolchain | ||
make purge-circular-symlinks | ||
- name: save toolchain cache | ||
id: save-toolchain-cache | ||
uses: actions/cache/save@v4 | ||
with: | ||
key: ${{ runner.os }}-openwrt-cache-toolchain-${{ matrix.build_env.tag }}-${{ matrix.build_env.pkgarch }}-${{ matrix.build_env.target }}-${{ matrix.build_env.subtarget }} | ||
path: | | ||
openwrt/.config | ||
openwrt/.config.old | ||
openwrt/feeds.conf | ||
openwrt/bin/** | ||
openwrt/build_dir/** | ||
openwrt/dl/** | ||
openwrt/feeds/** | ||
openwrt/package/** | ||
openwrt/staging_dir/** | ||
openwrt/tmp/** |
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ __pycache__ | |
create-test-env | ||
run-test-exporter-onetime | ||
tests/*.log.state | ||
loki-exporter/ |
Oops, something went wrong.