Skip to content

Commit

Permalink
[BOP-54] Run CI on a PR (#6)
Browse files Browse the repository at this point in the history
* Run CI on a PR

* Add a readme

* Additional ignores

* Add to README
  • Loading branch information
nwneisen authored Nov 2, 2023
1 parent bafbdec commit 108e41c
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/development.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GO_VERSION=1.21.3

UNIT_TEST_SCOPE=./cmd/... ./pkg/...
20 changes: 20 additions & 0 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PR

on:
pull_request:
types: ['opened', 'reopened', 'synchronize']
branches: [ "main" ]
paths:
- '**' # all files otherwise excludes wont work
- '!**/**/*.md' # ignore markdown files
- '!demo/**' # ignore demos folder
- '!sample/**' # ignore samples folder
- '!example/**' # ignore examples folder

jobs:
vet:
uses: ./.github/workflows/vet.yml
unit-test:
uses: ./.github/workflows/unit.yml
build:
uses: ./.github/workflows/build.yml
11 changes: 11 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Workflows

There are two types of workflows in this directory. I would put them in subfolders but GitHub doesn't support that.

## Callers

These are the high level workflows that can be associated with what triggers them. PRs, releases, nightlys, merges, etc. These are made up of jobs that are defined the the other workflows. These are the workflows that you will see in the Actions tab of the repo. By grouping these tasks into parent workflows, the jobs are grouped under one action in the actions tab. They share the smaller 'job' workflows so that they always run the same way. Convention has become to capitalize the first letter of these workflow's name.

## Jobs

These are the smaller individual tasks that are used to build up the larger parent workflows. They can be thought of as running unit tests, building the binaries, or linting the code. When you open one of the parent caller actions in the actions tab, they will show these individual jobs. Convention has become to lowercase the first letter of these workflow's name.
4 changes: 1 addition & 3 deletions .github/workflows/build.yaml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Build Docker Image

on:
pull_request:
types: [ opened, synchronize, reopened ]
branches: [ "main" ]
workflow_call:

jobs:
build:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Run Unit Tests

on:
workflow_call:

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Load environment
uses: c-py/action-dotenv-to-setenv@v4
with:
env-file: .github/development.env

- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Run Unit Tests
working-directory: .
run: make test
25 changes: 25 additions & 0 deletions .github/workflows/vet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Vet Go Code

on:
workflow_call:

jobs:
vet:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Load environment
uses: c-py/action-dotenv-to-setenv@v4
with:
env-file: .github/development.env

- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Vet Go Code
working-directory: .
run: make vet

0 comments on commit 108e41c

Please sign in to comment.