Skip to content

Commit

Permalink
Split linting and tests into new github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenWeathers committed Jun 27, 2023
1 parent a6059e4 commit f67c812
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 42 deletions.
24 changes: 8 additions & 16 deletions .github/workflows/go.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: Go
name: build

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
build:
timeout-minutes: 30
Expand Down Expand Up @@ -41,7 +45,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
id: go
Expand All @@ -50,7 +54,6 @@ jobs:
uses: actions/checkout@v3

- run: npm ci --no-optional
- run: npm run prettier
# - run: npm test
- run: npm run build
env:
Expand All @@ -68,19 +71,8 @@ jobs:
- name: Generate swagger docs
run: swag init -g http/http.go -o swaggerdocs

- name: Check formatting
uses: Jerome1337/gofmt-action@v1.0.5
with:
gofmt-path: '.'
gofmt-flags: '-l -d'

- name: Goimports Check
uses: DarthBenro008/goimports-check-action@v0.1.0
with:
root-path: './'

- name: Test
run: go test `go list ./... | grep -v swaggerdocs`
# - name: Test
# run: go test `go list ./... | grep -v swaggerdocs`

- name: Build
run: go build -v .
Expand Down
56 changes: 30 additions & 26 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ on:
schedule:
- cron: '28 23 * * 1'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
analyze:
name: Analyze
Expand All @@ -32,39 +36,39 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'go', 'javascript' ]
language: [ 'go', 'javascript', 'typescript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
56 changes: 56 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: lint
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
go:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.20' ]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}

- name: Check formatting
uses: Jerome1337/gofmt-action@v1.0.5
with:
gofmt-path: '.'
gofmt-flags: '-l -d'

- name: Goimports Check
uses: DarthBenro008/goimports-check-action@v0.1.0
with:
root-path: './'
ui:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ "18.5.0" ]

steps:
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Check out code
uses: actions/checkout@v3

- run: npm ci --no-optional
- run: npm run prettier
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: test

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
go:
runs-on: ubuntu-latest

strategy:
matrix:
go-version: [ "1.20" ]

steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Copy swagger docs dummy file and Create dummy dist/index.html
run: mkdir swaggerdocs && cp build/swaggerdocs_dummy.go swaggerdocs/docs.go && mkdir dist && touch dist/index.html

- name: Test
run: go test `go list ./... | grep -v swaggerdocs`
27 changes: 27 additions & 0 deletions build/swaggerdocs_dummy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package swaggerdocs

import "github.com/swaggo/swag"

const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"version": "{{.Version}}"
}
}`

var SwaggerInfo = &swag.Spec{
Version: "BETA",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "Thunderdome API",
Description: "Thunderdome Planning Poker API for both Internal and External use.\nWARNING: Currently not considered stable and is subject to change until 1.0 is released.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
}

func init() {
}

0 comments on commit f67c812

Please sign in to comment.