Skip to content

Commit

Permalink
feat: Add first test workflow
Browse files Browse the repository at this point in the history
Part of #2
  • Loading branch information
Gashmob committed Jul 15, 2024
1 parent 54524c9 commit 5ef01fb
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Tests

on:
push:
branches:
- master
pull_request:

jobs:
configure:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v27
- name: Build matrix json
uses: workflow/nix-shell-action@v3
with:
script: |
node ./tools/ci/generate_matrix.js
- name: Set matrix data
id: set-matrix
run: echo "matrix=$(jq -c . < ./tools/ci/workflow-matrix.json)" >> $GITHUB_OUTPUT

build:
name: Build & Run
needs: configure
strategy:
matrix: ${{ fromJson(needs.configure.outputs.matrix) }}
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v27
- name: Build then run
uses: workflow/nix-shell-action@v3
with:
script: |
bazel run //:filc
1 change: 1 addition & 0 deletions tools/ci/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workflow-matrix.json
16 changes: 16 additions & 0 deletions tools/ci/generate_matrix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const fs = require("node:fs");

const OUTPUT_FILE = __dirname + "/workflow-matrix.json";

const runners = ["ubuntu-latest", "macos-latest", "windows-latest"];

let result = [];

for (let runner of runners) {
result.push({
runner,
});
}

fs.writeFileSync(OUTPUT_FILE, JSON.stringify({includes: result}));

1 change: 1 addition & 0 deletions tools/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
[
(import ./pinned-bazel.nix { inherit pkgs; })
(import ./pinned-clang.nix { inherit pkgs; })
(import ./pinned-nodejs.nix { inherit pkgs; })
]
5 changes: 5 additions & 0 deletions tools/nix/pinned-nodejs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ pkgs }:

[
pkgs.nodejs_22
]

0 comments on commit 5ef01fb

Please sign in to comment.