Skip to content

Add a CI job to check that the manifest works #1

Add a CI job to check that the manifest works

Add a CI job to check that the manifest works #1

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- main
- master
workflow_dispatch:
inputs:
source:
description: 'Branch (user[/repo]:branch)'
type: string
required: false
os:
description: 'Machine type'
type: string
required: false
schedule:
- cron: '15 3 * * *'
jobs:
# The `setup` job determines the strategy for the real build job.
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
strategy: ${{ steps.strategy.outputs.result }}
steps:
- id: strategy
name: Determine build strategy
uses: actions/github-script@v6.4.1
with:
script: |
// Default settings.
const defaultSource = [
{ repo: "qmk/qmk_firmware", branch: "master" },
{ repo: "qmk/qmk_firmware", branch: "develop" },
];
const defaultOS = [
"ubuntu-latest",
];
// Read workflow inputs.
let inputSource = "";
let inputOS = "";
if (context.eventName == "workflow_dispatch") {
const payload = context.payload;
const inputs = payload && payload.inputs;
inputSource = inputs && inputs.source && inputs.source.trim() || "";
inputOS = inputs && inputs.os && inputs.os.trim() || "";
}
// Parse the `source` input.
let matrixSource = defaultSource;
if (inputSource != "") {
const sourceParts = inputSource.split(":", 2);
if (sourceParts.length == 2 ) {
let repoParts = sourceParts[0].split("/", 2);
if (repoParts.length == 1) {
repoParts.push("qmk_firmware");
}
matrixSource = [
{ repo: repoParts.join("/"), branch: sourceParts[1] },
];
}
}
// Parse the `os` input.
let matrixOS = defaultOS;
if (inputOS != "") {
matrixOS = [ inputOS ];
}
// Determine build strategy.
const strategy = {
"fail-fast": false,
"matrix": {
"source": matrixSource,
"os": matrixOS,
},
};
// Print the resulting strategy to the log.
core.startGroup("Job strategy:");
core.info(JSON.stringify(strategy, null, 2));
core.endGroup();
// Return the strategy as the step output in the JSON format.
return strategy;
test:
needs: setup
strategy: ${{ fromJSON(needs.setup.outputs.strategy) }}
defaults:
run:
shell: bash
working-directory: qmk_firmware
runs-on: ${{ matrix.os }}
steps:
- name: Guix cache
uses: actions/cache@v3.3.2
with:
path: ~/.cache/guix
key: guix-cache-${{ github.sha }}
restore-keys: |
guix-cache-
- name: Install Guix
uses: PromyLOPh/guix-install-action@v1.4
- name: Ensure no locale warning
working-directory: .
run: test -z "$(guix --version 2>&1 >/dev/null)"
- name: Checkout the project source
uses: actions/checkout@v4.1.1
with:
path: guix-qmk
- name: Build the Guix shell environment
working-directory: guix-qmk
run: guix shell -m manifest.scm -- true
- name: Checkout the QMK firmware source code
uses: actions/checkout@v4.1.1
with:
path: qmk_firmware
repository: ${{ matrix.source.repo }}
ref: ${{ matrix.source.branch }}
submodules: recursive
- name: Configure the 'upstream' remote
run: git remote add upstream https://github.com/qmk/qmk_firmware
- name: Configure the udev rules
if: ${{ runner.os == 'Linux' }}
run: sudo install -o root -g root -m 0644 util/udev/50-qmk.rules /etc/udev/rules.d/
- name: Update submodules
run: guix shell -m ../guix-qmk/manifest.scm -- make git-submodule
- name: Test 'qmk doctor'
run: guix shell -m ../guix-qmk/manifest.scm -- qmk doctor
- name: Test 'qmk setup'
run: |
# Test 'qmk setup'
# 'qmk setup' does not return the exit code of 'qmk doctor',
# therefore grepping the text output is needed.
guix shell -m ../guix-qmk/manifest.scm -- qmk setup 2>&1 | tee qmk-setup.log
grep -q "QMK is ready to go" qmk-setup.log
- name: Test AVR build using 'make'
run: guix shell -m ../guix-qmk/manifest.scm -- make planck/rev5:default
- name: Test Arm build using 'make'
run: guix shell -m ../guix-qmk/manifest.scm -- make planck/rev6:default
- name: Test 'make clean'
run: guix shell -m ../guix-qmk/manifest.scm -- make clean
- name: Force clean before testing 'qmk compile'
run: git clean -fdx
- name: Test AVR build using 'qmk compile'
run: guix shell -m ../guix-qmk/manifest.scm -- qmk compile -kb planck/rev5 -km default
- name: Test Arm build using 'qmk compile'
run: guix shell -m ../guix-qmk/manifest.scm -- qmk compile -kb planck/rev6 -km default
- name: Test 'qmk clean'
run: guix shell -m ../guix-qmk/manifest.scm -- qmk clean
finish:
needs:
- setup
- test
runs-on: ubuntu-latest
if: always()
env:
ci_success: >-
${{
(needs.setup.result == 'success')
&& (needs.test.result == 'success')
}}
steps:
- name: Report CI status
run: $ci_success