Skip to content

Commit

Permalink
add GitHub Actions CI
Browse files Browse the repository at this point in the history
  • Loading branch information
stapelberg committed Aug 1, 2024
1 parent d6a4144 commit c074024
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/create-bakery.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

set -eu

mkdir -p ~/gokrazy
mkdir ~/gokrazy/bakery || { echo 'bakery already exists' >&2; exit 1; }
# TODO: de-duplicate this config across {kernel,firmware} repositories
cat > ~/gokrazy/bakery/config.json <<EOT
{
"Hostname": "gokr-boot-will-inject-the-hostname",
"Update": {
"HTTPPassword": "${GOKRAZY_BAKERY_PASSWORD}"
},
"Packages": [
"github.com/gokrazy/breakglass",
"github.com/gokrazy/bakery/cmd/bake",
"github.com/gokrazy/timestamps",
"github.com/gokrazy/serial-busybox",
"github.com/gokrazy/wifi"
],
"PackageConfig": {
"github.com/gokrazy/breakglass": {
"CommandLineFlags": [
"-authorized_keys=/etc/breakglass.authorized_keys"
],
"ExtraFileContents": {
"/etc/breakglass.authorized_keys": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFGSGdjns3/K3vwrQvwtvEMruFIqDtV//CHWVLUm4XNt michael@midna"
}
}
},
"SerialConsole": "ttyS0,115200n8",
"KernelPackage": "github.com/gokrazy/kernel.amd64",
"FirmwarePackage": "github.com/gokrazy/kernel.amd64",
"EEPROMPackage": ""
}
}
EOT
40 changes: 40 additions & 0 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Update kernel ref

on:
schedule:
# daily, hour and minute chosen arbitrarily
- cron: '8 3 * * *'

jobs:

build:
name: CI
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
# Run on the latest minor release of Go 1.22:
go-version: ^1.22
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Ensure all files were formatted as per gofmt
run: |
[ "$(gofmt -l $(find . -name '*.go') 2>&1)" = "" ]
- name: Get dependencies
run: |
GOPROXY=direct go install github.com/gokrazy/autoupdate/cmd/gokr-pull-kernel@latest
- name: Update kernel reference if newer kernel is available
env:
GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }}
GH_USER: ${{ secrets.GH_USER }}
GH_AUTH_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
if: ${{ env.GH_USER != 0 }}
run: |
gokr-pull-kernel -updater_path=_build/upstream-url.txt
87 changes: 87 additions & 0 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Test Boot

on:
pull_request:
branches: [ main ]

jobs:

build:
name: CI
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
# Run on the latest minor release of Go 1.22:
go-version: ^1.22
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Ensure all files were formatted as per gofmt
run: |
[ "$(gofmt -l $(find . -name '*.go') 2>&1)" = "" ]
- name: Install dependencies
run: |
sudo apt update && sudo apt install qemu-system-x86
GOPROXY=direct go install github.com/gokrazy/autoupdate/cmd/...@latest
GOPROXY=direct go install github.com/gokrazy/tools/cmd/gok@latest
GOPROXY=direct go install github.com/gokrazy/bakery/cmd/qemubootery@latest
# TODO: once https://github.com/actions/runner/issues/662 is fixed, we can
# remove the gokr-has-label guards and terminate a CI run instead.
- name: Test Boot
env:
GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }}
GH_USER: ${{ secrets.GH_USER }}
GH_AUTH_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
TRAVIS_PULL_REQUEST: ${{ github.event.pull_request.number }}
TRAVIS_PULL_REQUEST_BRANCH: ${{ github.event.pull_request.head.ref }}
BOOTERY_URL: ${{ secrets.BOOTERY_URL }}
GOKRAZY_BAKERY_PASSWORD: ${{ secrets.GOKRAZY_BAKERY_PASSWORD }}
if: ${{ env.GH_USER != 0 }}
run: |
.github/workflows/create-bakery.bash
gok -i bakery add .
if gokr-has-label please-boot; then cd ~/gokrazy/bakery && GOARCH=amd64 gokr-boot -require_label=please-boot -set_label=please-boot-qemu -bootery_url=$BOOTERY_URL -update_root; fi
- name: Test Boot on qemu
env:
GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }}
GH_USER: ${{ secrets.GH_USER }}
GH_AUTH_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
TRAVIS_PULL_REQUEST: ${{ github.event.pull_request.number }}
TRAVIS_PULL_REQUEST_BRANCH: ${{ github.event.pull_request.head.ref }}
BOOTERY_URL: ${{ secrets.BOOTERY_URL }}
if: ${{ env.GH_USER != 0 }}
run: |
sed -i 's,"Hostname": "[^"]*","Hostname": "qemubakery",g' ~/gokrazy/bakery/config.json
if gokr-has-label please-boot-qemu; then cd ~/gokrazy/bakery && { qemubootery & GOARCH=amd64 gokr-boot -require_label=please-boot-qemu -set_label=please-merge -bootery_url=http://localhost:8037/testboot; }; fi
- name: Build Linux kernel and amend Pull Request
env:
GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }}
GH_USER: ${{ secrets.GH_USER }}
GH_AUTH_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
TRAVIS_PULL_REQUEST: ${{ github.event.pull_request.number }}
TRAVIS_PULL_REQUEST_BRANCH: ${{ github.event.pull_request.head.ref }}
BOOTERY_URL: ${{ secrets.BOOTERY_URL }}
if: ${{ env.GH_USER != 0 }}
run: |
if ! gokr-has-label please-merge && ! gokr-has-label please-boot && ! gokr-has-label please-boot-qemu; then (cd _build && gokr-rebuild-kernel -overwrite_container_executable=docker) && gokr-amend -set_label=please-boot lib vmlinuz; fi
- name: Merge if boot successful
env:
GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }}
GH_USER: ${{ secrets.GH_USER }}
GH_AUTH_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
TRAVIS_PULL_REQUEST: ${{ github.event.pull_request.number }}
TRAVIS_PULL_REQUEST_BRANCH: ${{ github.event.pull_request.head.ref }}
BOOTERY_URL: ${{ secrets.BOOTERY_URL }}
run: |
if gokr-has-label please-merge; then set +e; gokr-merge -require_label=please-merge; ret=$?; [ $ret -eq 2 ] || exit $ret; fi
31 changes: 31 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Push

on:
push:
branches: [ main ]

jobs:

build:
name: CI
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
# Run on the latest minor release of Go 1.22:
go-version: ^1.22
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Ensure all files were formatted as per gofmt
run: |
[ "$(gofmt -l $(find . -name '*.go') 2>&1)" = "" ]
- name: Build kernel
run: |
GOPROXY=direct go install github.com/gokrazy/autoupdate/cmd/gokr-rebuild-kernel@latest
(cd _build && gokr-rebuild-kernel)
1 change: 1 addition & 0 deletions _build/upstream-url.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.10.1.tar.xz

0 comments on commit c074024

Please sign in to comment.