Skip to content

Commit

Permalink
Merge pull request #26 from mdb/improve-acceptance-tests
Browse files Browse the repository at this point in the history
remove excessive recompilation in CI
  • Loading branch information
mdb committed Jan 20, 2023
2 parents 3b484ea + b25fc0b commit 79e40f4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/cicd.yaml
Expand Up @@ -8,21 +8,21 @@ jobs:
build-and-test-snapshot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Build
run: make
- name: Install gh dispatch
run: make install
- name: Acceptance test
run: make acc-test
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Ensure unique version
run: make check-tag
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Build
run: make
- name: Install gh dispatch
run: make install
- name: Acceptance test
run: make acc-test
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Ensure unique version
run: make check-tag

build-and-publish-release:
if: github.ref == 'refs/heads/main'
Expand Down
2 changes: 1 addition & 1 deletion Makefile
@@ -1,6 +1,6 @@
SOURCE=./...
GOFMT_FILES?=$$(find . -type f -name '*.go')
VERSION?=0.1.3
VERSION?=0.1.4

default: build

Expand Down
12 changes: 0 additions & 12 deletions cmd/main_test.go
Expand Up @@ -5,7 +5,6 @@ package main

import (
"fmt"
"os"
"os/exec"
"strings"
"testing"
Expand All @@ -15,17 +14,6 @@ import (
"github.com/stretchr/testify/assert"
)

func TestMain(m *testing.M) {
// compile a 'gh-dispatch' for for use in running tests
exe := exec.Command("go", "build", "-ldflags", "-X main.version=test", "-o", "gh-dispatch")
err := exe.Run()
if err != nil {
os.Exit(1)
}

os.Exit(m.Run())
}

func TestRootAcceptance(t *testing.T) {
basicOut := heredoc.Doc(`Send a workflow_dispatch or repository_dispatch event and watch the resulting
GitHub Actions run.
Expand Down
2 changes: 1 addition & 1 deletion scripts/ensure-unique-version.sh
Expand Up @@ -6,7 +6,7 @@ repo="mdb/gh-dispatch"
result="$(curl \
--header "Accept: application/vnd.github.v3+json" \
--write "%{http_code}" \
--out "/dev/null" \
--output "/dev/null" \
"https://api.github.com/repos/${repo}/releases/tags/${version}")"

if [ "${result}" = "404" ]; then
Expand Down

0 comments on commit 79e40f4

Please sign in to comment.