Prompts for GPT
User
Next, please add an appropriate CI process to my project to ensure that the code committed to the main branch can be built normally and all unit tests pass. You can use GitHub Actions directly.
DevChat
Sure, we can create a GitHub Actions workflow to run the build and unit tests every time a commit is made to the main branch. Here is a basic GitHub Actions workflow configuration file .github/workflows/ci.yml
:
name: CI
on:
push:
branches:
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: go get -v -t -d ./...
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
This workflow will run every time a commit is made to the main branch. It first sets up the Go environment, then checks out the code, gets dependencies, builds the project, and finally runs all unit tests.
You need to add this file to the .github/workflows
directory in your project. If this directory does not exist yet, you need to create it.