Skip to content

Commit

Permalink
feat: add go build and test
Browse files Browse the repository at this point in the history
  • Loading branch information
WolverMinion authored Sep 24, 2023
1 parent 60cdc9e commit 75a274c
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 3 deletions.
65 changes: 65 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG-REPORT.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "🐛 Bug Report"
description: Create a new ticket for a bug.
title: "🐛 [BUG] - <title>"
labels: [
"bug"
]
body:
- type: textarea
id: description
attributes:
label: "Description"
description: Please enter an explicit description of your issue
placeholder: Short and explicit description of your incident...
validations:
required: true
- type: input
id: reprod-url
attributes:
label: "Reproduction URL"
description: Please enter your GitHub URL to provide a reproduction of the issue
placeholder: ex. https://github.com/USERNAME/REPO-NAME
validations:
required: true
- type: textarea
id: reprod
attributes:
label: "Reproduction steps"
description: Please enter an explicit description of your issue
value: |
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
render: bash
validations:
required: true
- type: textarea
id: screenshot
attributes:
label: "Screenshots"
description: If applicable, add screenshots to help explain your problem.
value: |
![DESCRIPTION](LINK.png)
render: bash
validations:
required: false
- type: textarea
id: logs
attributes:
label: "Logs"
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: bash
validations:
required: false
- type: dropdown
id: os
attributes:
label: "OS"
description: What is the impacted environment ?
multiple: true
options:
- Windows
- Linux
validations:
required: false
63 changes: 63 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE-REQUEST.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "💡 Feature Request"
description: Create a new ticket for a new feature request
title: "💡 [REQUEST] - <title>"
labels: [
"question"
]
body:
- type: input
id: start_date
attributes:
label: "Start Date"
description: Start of development
placeholder: "month/day/year"
validations:
required: false
- type: textarea
id: implementation_pr
attributes:
label: "Implementation PR"
description: Pull request used
placeholder: "#Pull Request ID"
validations:
required: false
- type: textarea
id: reference_issues
attributes:
label: "Reference Issues"
description: Common issues
placeholder: "#Issues IDs"
validations:
required: false
- type: textarea
id: summary
attributes:
label: "Summary"
description: Provide a brief explanation of the feature
placeholder: Describe in a few lines your feature request
validations:
required: true
- type: textarea
id: basic_example
attributes:
label: "Basic Example"
description: Indicate here some basic examples of your feature.
placeholder: A few specific words about your feature request.
validations:
required: true
- type: textarea
id: drawbacks
attributes:
label: "Drawbacks"
description: What are the drawbacks/impacts of your feature request ?
placeholder: Identify the drawbacks and impacts while being neutral on your feature request
validations:
required: true
- type: textarea
id: unresolved_question
attributes:
label: "Unresolved questions"
description: What questions still remain unresolved ?
placeholder: Identify any unresolved issues.
validations:
required: false
11 changes: 10 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,13 @@ updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
interval: daily
open-pull-requests-limit: 99
target-branch: main
commit-message:
prefix: "fix prod"
prefix-development: "fix dev"
include: scope
labels:
- "go"
- "dependencies"
112 changes: 112 additions & 0 deletions .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: "CI/CD for Go"

on: push

jobs:
get-next-version:
runs-on: ubuntu-latest
steps:
- name: "checkout"
uses: actions/checkout@v3
- name: "get branch name"
id: extract_branch_name
shell: bash
run: |
branch_name=$(git rev-parse --abbrev-ref HEAD)
echo "::set-output name=branch::$(echo ${branch_name})"
- name: "setup node"
uses: actions/setup-node@v3
with:
node-version: 19
- name: "init npm"
run: npm init -y
- name: "semantic release - get next version"
id: get-next-version
uses: cycjimmy/semantic-release-action@v3
with:
dry_run: true
#semantic_version: 20.0.2
# you can set branch for semantic-release older than v16.
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'${{ steps.extract_branch_name.outputs.branch }}'
]
env:
#GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: "check outputs and env"
run: |
echo "check the result from step `get-next-version`"
pwd
ls -la
set
echo """
new_release_published: ${{ steps.get-next-version.outputs.new_release_published }}
new_release_version: ${{ steps.get-next-version.outputs.new_release_version }}
new_release_major_version: ${{ steps.get-next-version.outputs.new_release_major_version }}
last_release_version: ${{ steps.get-next-version.outputs.last_release_version }}
"""
outputs:
new-release-published: ${{ steps.get-next-version.outputs.new_release_published }}
new-release-version: ${{ steps.get-next-version.outputs.new_release_version }}

build:
runs-on: ubuntu-latest
needs:
- get-next-version
if: needs.get-next-version.outputs.new-release-version != ''
steps:
- uses: actions/checkout@v3

- name: Set up Go environment
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Test
shell: bash
run: |
chmod u+x test.sh
./test.sh
- name: Build
shell: bash
env:
APP_VERSION: ${{ needs.get-next-version.outputs.new-release-version }}
run: |
echo "new release version: ${{ env.APP_VERSION }}"
chmod u+x build.sh
./build.sh ${{ env.APP_VERSION }}
release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: "setup node"
uses: actions/setup-node@v3
with:
node-version: 19
- name: "init npm"
run: npm init -y
- name: "semantic release - create new release"
id: create-new-release
uses: cycjimmy/semantic-release-action@v3
with:
dry_run: false
#semantic_version: 20.0.2
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main'
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
6 changes: 6 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"branches": [
"main",
{ "name": "feat/workflow-build", "prerelease": true }
]
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# github-config

Github configuration sync as code

[![CI/CD for Go](https://github.com/Continuous-X/github-config/actions/workflows/ci-go.yml/badge.svg)](https://github.com/Continuous-X/github-config/actions/workflows/ci-go.yml)
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# GoLang cross-compile snippet for Go 1.6+ based loosely on Dave Chaney's cross-compile script:
# http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
Expand Down
2 changes: 1 addition & 1 deletion dependency-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ dependency-check.sh --project github-config \
--nonProxyHosts "" \
--disableAssembly

# --suppression dependency-check-suppression.xml \
# --suppression dependency-check-suppression.xml \
5 changes: 5 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
go test ./... -count=1 -cover -p 4 -coverprofile=coverage.out
go tool cover -func coverage.out
go tool cover -html=coverage.out -o cx-installer.html
echo "Code-Coverage in Summe beträgt: $(go tool cover -func coverage.out | grep total | awk '{print $3}')"

0 comments on commit 75a274c

Please sign in to comment.