diff --git a/.github/workflows/common/base.cue b/.github/workflows/common/base.cue new file mode 100644 index 000000000..d0f53fd57 --- /dev/null +++ b/.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" +}] diff --git a/.github/workflows/default.cue b/.github/workflows/default.cue index 3217bd714..84f7fa22d 100644 --- a/.github/workflows/default.cue +++ b/.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 """ diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index b61f47de7..af0daada4 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -1,6 +1,5 @@ -name: hof +name: hof-test on: -- push - pull_request jobs: test: @@ -8,6 +7,7 @@ jobs: matrix: go-version: - 1.16.x + - 1.17.x os: - ubuntu-latest - macos-latest @@ -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: {} diff --git a/.github/workflows/test/mod.cue b/.github/workflows/test/mod.cue new file mode 100644 index 000000000..9b0c6068d --- /dev/null +++ b/.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}}" + } + }] + } +} + diff --git a/.github/workflows/test/mod.yml b/.github/workflows/test/mod.yml new file mode 100644 index 000000000..46d6e9ba0 --- /dev/null +++ b/.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}} diff --git a/Makefile b/Makefile index c2a023158..0971f0ece 100644 --- a/Makefile +++ b/Makefile @@ -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