From 167cb90c650c26fc789371a631433748073dcf32 Mon Sep 17 00:00:00 2001 From: Colin Senner Date: Sat, 4 Jan 2025 13:36:25 -0800 Subject: [PATCH] feat: Add test runner to all pull requests against master (#204) This PR adds a new ci/cd workflow that runs when a PR is made against master. You will (likely) want to enable a few repository options in github to ensure this isn't bypassed, but it's up to you: - Branch protection on master which requires a PR to merge - CI/CD must pass before merging a PR --- .../{build.yml => build-and-release.yml} | 25 +++++++++++++------ .github/workflows/run-tests.yml | 20 +++++++++++++++ .gitignore | 3 +-- 3 files changed, 38 insertions(+), 10 deletions(-) rename .github/workflows/{build.yml => build-and-release.yml} (87%) create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build-and-release.yml similarity index 87% rename from .github/workflows/build.yml rename to .github/workflows/build-and-release.yml index 2a379f53..e576a534 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build-and-release.yml @@ -1,11 +1,12 @@ # This workflow will: build gomud for multiple os/architectures # archive the binaries and create a new release for users to easily download -name: Go +name: Build and release on: push: - branches: ["master", "ci-cd-releases"] + branches: [master] + workflow_dispatch: permissions: contents: write @@ -14,14 +15,22 @@ env: RELEASE_FILENAME: go-mud-release jobs: - # test: - # runs-on: ubuntu-latest - # steps: - # - name: Test - # run: go test -v ./... + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.23" + + - name: Run tests + run: go test ./... build: runs-on: ubuntu-latest + needs: "test" steps: - uses: actions/checkout@v4 @@ -59,7 +68,7 @@ jobs: release: runs-on: ubuntu-latest - needs: build + needs: "build" steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 00000000..0f939c8f --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,20 @@ +name: run-tests + +on: + pull_request: + branches: [master] + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.23" + + - name: Run tests + run: go test ./... diff --git a/.gitignore b/.gitignore index 9e7ebc2c..53ec530a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .vscode private-notes.txt **/users/* -**/config-overrides.yaml -bin/ \ No newline at end of file +**/config-overrides.yaml \ No newline at end of file