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

Feature/goinit #5

Merged
merged 6 commits into from
Sep 30, 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
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
groups:
dependencies:
patterns:
- "*"
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Go

on:
push:
branches: [ "main", "feature" ]
pull_request:
branches: [ "main", "feature" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
58 changes: 58 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '0 6 * * 5'

jobs:
analyze:
name: Analyze
runs-on: 'ubuntu-latest'
env:
GOPRIVATE: github.com/ARK-Builders/*
GH_ACCESS_TOKEN: ${{ secrets.GH_ACTIONS_CI_TOKEN }}
timeout-minutes: 360
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- run: git config --global url.https://[email protected]/.insteadOf https://github.com/
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, 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@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
31 changes: 31 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: SonarCloud
on:
push:
branches:
- feature
- main
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
env:
GH_ACCESS_TOKEN: ${{ secrets.GH_ACTIONS_CI_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
- name: Prepare coverage
run: |
git config --global url.https://[email protected]/.insteadOf https://github.com/
go test ./... -parallel 4 -coverpkg=./... -coverprofile=coverage.out -json > coverage-report.json
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ARK-Builders_ark-p2p&metric=coverage)](https://sonarcloud.io/summary/new_code?id=ARK-Builders_ark-p2p)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=ARK-Builders_ark-p2p&metric=bugs)](https://sonarcloud.io/summary/new_code?id=ARK-Builders_ark-p2p)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=ARK-Builders_ark-p2p&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=ARK-Builders_ark-p2p)
Comment on lines +1 to +3
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be active after merging to the main branch


# ark-p2p
Connectivity library for ARK apps
5 changes: 5 additions & 0 deletions entry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ark_p2p

func HelloWorld() string {
return "Hello World"
}
32 changes: 32 additions & 0 deletions entry_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ark_p2p

import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestHelloWorld(t *testing.T) {
tests := []struct {
title string
assert func(t *testing.T, res any)
}{
{
title: "Check Method not empty",
assert: func(t *testing.T, res any) {
assert.Greater(t, len(res.(string)), 0)
},
},
{
title: "Check result equal Hello world",
assert: func(t *testing.T, res any) {
assert.Equal(t, "Hello World", res)
},
},
}

for _, tt := range tests {
t.Run(tt.title, func(t *testing.T) {
tt.assert(t, HelloWorld())
})
}
}
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/ARK-Builders/ark-p2p

go 1.21

require github.com/stretchr/testify v1.8.4

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
17 changes: 17 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sonar.projectKey=ARK-Builders_ark-p2p
sonar.organization=ark-builders

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=ebc-cop_srv
#sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
sonar.sources=.
sonar.exclusions=**/*_test.go
sonar.tests=.
sonar.test.inclusions=**/*_test.go
sonar.go.tests.reportPaths=coverage-report.json
sonar.go.coverage.reportPaths=coverage.out

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8