Skip to content

Commit

Permalink
Initial GH Workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
soumeh01 committed Sep 13, 2023
1 parent 6de5e4a commit 63227f0
Show file tree
Hide file tree
Showing 18 changed files with 591 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
rebase-strategy: disabled
15 changes: 15 additions & 0 deletions .github/markdown-link-check.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ignorePatterns": [
{
"pattern": "^https://opensource.org"
}
],
"httpHeaders": [
{
"urls": ["https://github.com/", "https://guides.github.com/", "https://help.github.com/", "https://docs.github.com/"],
"headers": {
"Accept-Encoding": "zstd, br, gzip, deflate"
}
}
],
}
18 changes: 18 additions & 0 deletions .github/markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "markdownlint",
"severity": "warning",
"pattern": [
{
"regexp": "^(.*):(\\d+)(:(\\d+))? (MD\\d+\\/[^ ]+) (.*)$",
"file": 1,
"line": 2,
"column": 4,
"code": 5,
"message": 6
}
]
}
]
}
11 changes: 11 additions & 0 deletions .github/markdownlint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"default": true,
"MD013": {
"line_length": 120
},
"MD014": false,
"MD029": false,
"MD025": false,
"MD034": false,
"MD041": false
}
58 changes: 58 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build

on:
push:
branches: [ main ]
pull_request:
paths:
- '.github/workflows/build.yml'
- '**/*.go'
- 'makefile'
- 'go.mod'
- 'go.sum'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
strategy:
matrix:
goos: [windows, linux, darwin]
arch: [amd64, arm64]

name: "${{ matrix.goos }} | ${{ matrix.arch }}"
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go
queries: security-and-quality

- name: Build
run: |
make OS=${{ matrix.goos }} ARCH=${{ matrix.arch }} build
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: cbridge-${{ matrix.goos }}-${{ matrix.arch }}
path: build/cbridge*
retention-days: 1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
40 changes: 40 additions & 0 deletions .github/workflows/markdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Markdown

on:
pull_request:
paths:
- '.github/workflows/markdown.yml'
- '.github/markdownlint.json'
- '.github/markdownlint.jsonc'
- '**/*.md'
jobs:
markdown-lint:
name: Lint markdown files
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Register markdownlint warning matcher
run: echo "::add-matcher::.github/markdownlint.json"

- name: Lint markdown files
uses: avto-dev/markdown-lint@v1
with:
args: '**/*.md'
config: '.github/markdownlint.jsonc'
ignore: 'third_party_licenses.md'

- name: Remove markdownlint warning matcher
if: always()
run: echo "::remove-matcher owner=markdownlint::"

- uses: gaurav-nelson/github-action-markdown-link-check@master
if: always()
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
check-modified-files-only: 'yes'
base-branch: ${{ github.base_ref }}
config-file: '.github/markdown-link-check.jsonc'
153 changes: 153 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: Test

on:
workflow_dispatch:
push:
branches: [main]
pull_request:
paths:
- '.github/workflows/test.yml'
- '**/*.go'
- 'makefile'
- 'go.mod'
- 'go.sum'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
program: "cbridge"

jobs:
lint:
name: Lint
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true

- name: Lint with golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest

format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true

- name: Check formatting
run: make format-check

vulnerability-check:
name: "Vulnerability check"
runs-on: ubuntu-latest
steps:
- name: Scan for Vulnerabilities
uses: golang/govulncheck-action@v1
with:
go-version-input: 1.20.6
go-package: ./...

test:
strategy:
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
arch: [amd64, arm64]
include:
- platform: ubuntu-latest
target: linux
- platform: windows-latest
target: windows
- platform: macos-latest
target: darwin
name: 'Test (${{ matrix.target }}, ${{ matrix.arch }})'
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true

- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest

- name: Run tests
run: |
mkdir -p build
set GOOS=${{ matrix.target }} && set GOARCH=${{ matrix.arch }} && go test -v ./... > build/${{ env.program }}-${{ matrix.target }}-${{ matrix.arch }}.txt
- name: Generate HTML report
if: success() || failure()
run: |
go-junit-report -set-exit-code -in build/${{ env.program }}-${{ matrix.target }}-${{ matrix.arch }}.txt -iocopy -out build/${{ env.program }}-testreport-${{ matrix.target }}-${{ matrix.arch }}.xml
- name: Archive test results
uses: actions/upload-artifact@v3
with:
name: ${{ env.program }}-test-result-${{ matrix.target }}-${{ matrix.arch }}
path: ./build/${{ env.program }}-testreport-*.xml
retention-days: 1
if-no-files-found: error

publish-test-results:
if: github.event_name != 'release'
name: "Publish Tests Results"
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts

- name: publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "artifacts/**/${{ env.program }}-testreport-*.xml"
report_individual_runs: true

coverage:
if: github.event_name != 'release'
needs: [ test ]
name: 'Coverage check'
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true

- name: Unit testing
run: |
make coverage-check
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./cover.out
fail_ci_if_error: true
functionalities: fix
74 changes: 74 additions & 0 deletions .github/workflows/tpip-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: TPIP Check

on:
workflow_dispatch:
pull_request:
paths:
- ".github/workflows/tpip-check.yml"
- "**/go.mod"
- "**/go.sum"
- "template/**"

env:
report_name: "third_party_licenses.md"

jobs:
check-licenses:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true

- name: Go tidy
run: go mod tidy

- name: Install go-licenses
run: go install github.com/google/go-licenses@latest

- name: Generate TPIP Report
run: |
go-licenses report . --ignore github.com/Open-CMSIS-Pack/generator-bridge --template ../template/${{ env.report_name }}.template > ../${{ env.report_name }}
date +"%Y/%m/%d %T" >> ../${{ env.report_name }}
working-directory: ./cmd

- name: Archive tpip report
uses: actions/upload-artifact@v3
with:
name: tpip-report
path: ./${{ env.report_name }}

- name: Print TPIP Report
run: cat ${{ env.report_name }} >> $GITHUB_STEP_SUMMARY

- name: Check Licenses
run: go-licenses check . --ignore github.com/Open-CMSIS-Pack/generator-bridge --disallowed_types=forbidden,restricted

commit-changes:
needs: [ check-licenses ]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Restore Changes
uses: actions/download-artifact@v3
with:
name: tpip-report

- name: Commit Changes
shell: bash
run: |
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Update TPIP report"
git push
Loading

0 comments on commit 63227f0

Please sign in to comment.