build: package the build in a flake and test with propogated timing #317
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: Makes valid measurements | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
checkup: | |
name: Inspect the code health | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install a flaked Nix | |
uses: DeterminateSystems/nix-installer-action@v16 | |
- name: Install dependencies | |
run: nix develop -c go get | |
- name: Check formatting | |
run: nix develop -c make check | |
- name: Build binary | |
run: nix develop -c make build | |
- name: Run tests | |
run: nix develop -c go test -v ./... -coverprofile=coverage.txt | |
- name: Upload coverage results | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
measurement: | |
name: Monitor energy usage | |
needs: checkup | |
runs-on: self-hosted | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Reflect existing Nix | |
id: nixos | |
continue-on-error: true | |
run: uname -a | grep NixOS | |
- name: Install a flaked Nix | |
if: steps.nixos.outcome != 'success' | |
uses: DeterminateSystems/nix-installer-action@v16 | |
- name: Clean the environment | |
run: nix develop -c make clean | |
- name: Sleep for a short while | |
run: | | |
nix shell nixpkgs#time | |
nix run . -- sleep 4 | |
env: | |
EMPORIA_DEVICE: ${{ secrets.EMPORIA_DEVICE }} | |
EMPORIA_USERNAME: ${{ secrets.EMPORIA_USERNAME }} | |
EMPORIA_PASSWORD: ${{ secrets.EMPORIA_PASSWORD }} | |
- name: Sleep for a bit longer | |
run: nix run . -- sleep 12 | |
env: | |
EMPORIA_DEVICE: ${{ secrets.EMPORIA_DEVICE }} | |
EMPORIA_USERNAME: ${{ secrets.EMPORIA_USERNAME }} | |
EMPORIA_PASSWORD: ${{ secrets.EMPORIA_PASSWORD }} |