Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codeformat checks #423

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 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 @@ -36,12 +40,12 @@ jobs:

steps:
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
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 @@ -67,8 +71,8 @@ jobs:
- name: Generate swagger docs
run: swag init -g http/http.go -o swaggerdocs

- 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
4 changes: 2 additions & 2 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- run: go install github.com/swaggo/swag/cmd/[email protected]
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci --no-optional
Expand Down
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/[email protected]
with:
gofmt-path: '.'
gofmt-flags: '-l -d'

- name: Goimports Check
uses: DarthBenro008/[email protected]
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@v3
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`
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SWAGGERGEN=swag init -g http/http.go -o swaggerdocs
SWAGGERDOCS=swaggerdocs
GOFMT=gofmt
GOIMPORTS=goimports
NPM_FORMAT=npm run format
BINARY_NAME=thunderdome-planning-poker
BINARY_UNIX=$(BINARY_NAME)_unix
BINARY_WINDOWS=thunderdome-planning-poker.exe
Expand All @@ -31,8 +32,9 @@ clean:
rm -rf $(SWAGGERDOCS)

format:
$(GOFMT) -s -w */*.go
$(GOIMPORTS) -w */*.go
$(GOFMT) -s -w .
$(GOIMPORTS) -w .
$(NPM_FORMAT)

testgo:
go test `go list ./... | grep -v swaggerdocs`
Expand Down
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() {
}
Loading