Skip to content

Commit

Permalink
start breaking out more GHA workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Worm <tony@hofstadter.io>
  • Loading branch information
verdverm committed Aug 24, 2021
1 parent 072d279 commit 94567c1
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 40 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/common/base.cue
@@ -0,0 +1,31 @@
package common

import "github.com/hofstadter-io/ghacue"

#Workflow: ghacue.#Workflow & {
name: string
on: _ | *["pull_request"]
jobs: test: {
strategy: matrix: {
"go-version": ["1.16.x", "1.17.x"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
}
strategy: "fail-fast": false
"runs-on": "${{ matrix.os }}"
}
}

#BuildSteps: [{
name: "Install Go"
uses: "actions/setup-go@v2"
with: "go-version": "${{ matrix.go-version }}"
},{
name: "Checkout code"
uses: "actions/checkout@v2"
},{
name: "Download mods"
run: "go mod download"
},{
name: "Build CLI"
run: "go install ./cmd/hof"
}]
37 changes: 7 additions & 30 deletions .github/workflows/default.cue
@@ -1,39 +1,16 @@
import "github.com/hofstadter-io/ghacue"
import "github.com/hofstadter-io/hof/.github/workflows/common"

ghacue.#Workflow & {
name: "hof"
on: ["push", "pull_request"]
common.#Workflow & {
name: "hof-test"
on: ["pull_request"]
jobs: test: {
strategy: matrix: {
"go-version": ["1.16.x"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
}
strategy: "fail-fast": false
"runs-on": "${{ matrix.os }}"
steps: [{
name: "Install Go"
uses: "actions/setup-go@v2"
with: "go-version": "${{ matrix.go-version }}"
},{
name: "Checkout code"
uses: "actions/checkout@v2"
},{
name: "Download mods"
run: "go mod download"
},{
name: "Build CLI"
run: "go install ./cmd/hof"
},{
name: "Run tests"
steps: [ for step in common.#BuildSteps {step} ] + [{
name: "Run gen tests"
run: """
hof test test.cue -s gen -t test
hof test test.cue -s lib -t test -t mod
"""
env: {
GITHUB_TOKEN: "${{secrets.HOFMOD_TOKEN}}"
}
},{
name: "Run extra tests"
name: "Run tester tests"
run: """
hof test test/testers/api/postman.cue
"""
Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/default.yml
@@ -1,13 +1,13 @@
name: hof
name: hof-test
on:
- push
- pull_request
jobs:
test:
strategy:
matrix:
go-version:
- 1.16.x
- 1.17.x
os:
- ubuntu-latest
- macos-latest
Expand All @@ -25,12 +25,7 @@ jobs:
run: go mod download
- name: Build CLI
run: go install ./cmd/hof
- name: Run tests
run: |-
hof test test.cue -s gen -t test
hof test test.cue -s lib -t test -t mod
env:
GITHUB_TOKEN: ${{secrets.HOFMOD_TOKEN}}
- name: Run extra tests
- name: Run gen tests
run: hof test test.cue -s gen -t test
- name: Run tester tests
run: hof test test/testers/api/postman.cue
services: {}
20 changes: 20 additions & 0 deletions .github/workflows/test/mod.cue
@@ -0,0 +1,20 @@
import "github.com/hofstadter-io/hof/.github/workflows/common"

common.#Workflow & {
name: "mod-test"
on: pull_request: {
paths: ["lib/mod/**"]
}
jobs: test: {
steps: [ for step in common.#BuildSteps {step} ] + [{
name: "Run mod tests"
run: """
# hof test test.cue -s lib -t test -t mod
"""
env: {
GITHUB_TOKEN: "${{secrets.HOFMOD_TOKEN}}"
}
}]
}
}

33 changes: 33 additions & 0 deletions .github/workflows/test/mod.yml
@@ -0,0 +1,33 @@
name: mod-test
on:
pull_request:
paths:
- lib/mod/**
jobs:
test:
strategy:
matrix:
go-version:
- 1.16.x
- 1.17.x
os:
- ubuntu-latest
- macos-latest
- windows-latest
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Download mods
run: go mod download
- name: Build CLI
run: go install ./cmd/hof
- name: Run mod tests
run: '# hof test test.cue -s lib -t test -t mod'
env:
GITHUB_TOKEN: ${{secrets.HOFMOD_TOKEN}}
9 changes: 9 additions & 0 deletions Makefile
Expand Up @@ -21,3 +21,12 @@ cloccode: cmd lang lib gen cmd

clocdev: hof.cue design schema lang lib docs test cue.mods go.mod
cloc --read-lang-def=$$HOME/hof/jumpfiles/assets/cloc_defs.txt --exclude-dir=cue.mod,vendor $^

WORKFLOWS = default \
test/mod

.PHONY: workflow
workflows = $(addprefix workflow_, $(WORKFLOWS))
workflow: $(workflows)
$(workflows): workflow_%:
@cue export --out yaml .github/workflows/$(subst workflow_,,$@).cue > .github/workflows/$(subst workflow_,,$@).yml

0 comments on commit 94567c1

Please sign in to comment.