Skip to content

Commit

Permalink
rework main workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kayra1 committed May 7, 2024
1 parent 46151bc commit 510f332
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 90 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/main-jobs/build-gocert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build GoCert

on:
workflow_call:

jobs:
nextjs-build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ui
steps:
- uses: actions/checkout@v3
- name: Use npm
uses: actions/setup-node@v4

- name: Build frontend
run: |
npm install
npm run build
go-build:
runs-on: ubuntu-latest
needs: [nextjs-build]
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Build
run: go build ./...
19 changes: 19 additions & 0 deletions .github/workflows/main-jobs/go-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Lint

on:
workflow_call:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: golangci-lint
uses: golangci/golangci-lint-action@v5
with:
version: v1.54
17 changes: 17 additions & 0 deletions .github/workflows/main-jobs/go-vet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Vet

on:
workflow_call:

jobs:
go-vet:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Go vet
run: go vet ./...
32 changes: 32 additions & 0 deletions .github/workflows/main-jobs/test-gocert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Unit Test GoCert

on:
workflow_call:

jobs:
nextjs-unit-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ui
steps:
- uses: actions/checkout@v3
- name: Use npm
uses: actions/setup-node@v4

- name: Build frontend
run: |
npm install
npm run test
go-unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Unit tests
run: go test -cover ./...

103 changes: 13 additions & 90 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,102 +8,25 @@ on:
branches:
- main

jobs:
go-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Build
run: go build ./...
nextjs-build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ui
steps:
- uses: actions/checkout@v3
- name: Use npm
uses: actions/setup-node@v4

- name: Build frontend
run: |
npm install
npm run build
jobs:
build-gocert:
uses: ./.github/workflows/main-jobs/build-gocert.yaml
unit-test-gocert:
needs: [build-gocert]
uses: ./.github/workflows/main-jobs/test-gocert.yaml
go-vet:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Go vet
run: go vet ./...

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: golangci-lint
uses: golangci/golangci-lint-action@v5
with:
version: v1.54

go-unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Unit tests
run: go test -cover ./...

nextjs-unit-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ui
steps:
- uses: actions/checkout@v3
- name: Use Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Execute Unit tests
run: |
bun install
bun run test
needs: [build-gocert]
uses: ./.github/workflows/main-jobs/go-vet.yaml
go-lint:
needs: [build-gocert]
uses: ./.github/workflows/main-jobs/go-lint.yaml
rock-build:
needs:
- go-build
- nextjs-build
- go-vet
- lint
- go-unit-tests
- nextjs-unit-tests
needs: [build-gocert, unit-test-gocert, go-vet, go-lint]
uses: ./.github/workflows/build-rock.yaml

rock-scan:
if: github.ref_name == 'main'
needs: rock-build
needs: [rock-build]
uses: ./.github/workflows/scan-rock.yaml

publish:
if: github.ref_name == 'main'
needs: [rock-build]
Expand Down

0 comments on commit 510f332

Please sign in to comment.