Updating GH workflows + Sonar (#514)

* Updating GH workflows + Sonar

* adding missing step to build
This commit is contained in:
Mzack9999 2022-02-09 10:09:30 +01:00 committed by GitHub
parent 09b278bc86
commit 5a562107f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 127 additions and 34 deletions

View File

@ -15,16 +15,20 @@ updates:
commit-message:
prefix: "chore"
include: "scope"
labels:
- "Type: Maintenance"
# Maintain dependencies for go modules
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
interval: "daily"
target-branch: "dev"
commit-message:
prefix: "chore"
include: "scope"
labels:
- "Type: Maintenance"
# Maintain dependencies for docker
- package-ecosystem: "docker"
@ -34,4 +38,6 @@ updates:
target-branch: "dev"
commit-message:
prefix: "chore"
include: "scope"
include: "scope"
labels:
- "Type: Maintenance"

View File

@ -5,25 +5,38 @@ on:
pull_request:
workflow_dispatch:
jobs:
build:
name: Test Builds
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Test
run: go test ./...
- name: Integration Tests
run: bash run.sh
working-directory: integration_tests/
- name: Check out code
uses: actions/checkout@v2
- name: Build
run: go build .
working-directory: cmd/httpx/
- name: Test
run: go test ./...
working-directory: .
- name: Integration Tests
env:
GH_ACTION: true
run: bash run.sh
working-directory: integration_tests/
- name: Race Condition Tests
run: go build -race .
working-directory: cmd/httpx/

View File

@ -2,6 +2,7 @@ name: 🚨 CodeQL Analysis
on:
workflow_dispatch:
push:
pull_request:
branches:
- dev

View File

@ -4,11 +4,13 @@ on:
pull_request:
workflow_dispatch:
jobs:
functional:
name: Functional Test
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Set up Go
uses: actions/setup-go@v2
@ -21,5 +23,5 @@ jobs:
- name: Functional Tests
run: |
chmod +x run.sh
bash run.sh
bash run.sh ${{ matrix.os }}
working-directory: cmd/functional-test

View File

@ -9,18 +9,21 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
- name: "Check out code"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "Set up Go"
uses: actions/setup-go@v2
with:
go-version: 1.17
-
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
name: "Create release on GitHub"
- name: "Create release on GitHub"
uses: goreleaser/goreleaser-action@v2
with:
with:
args: "release --rm-dist"
version: latest
workdir: .
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

38
.github/workflows/sonarcloud.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: 👮🏼‍♂️ Sonarcloud
on:
push:
branches:
- master
- dev
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
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@v2
with:
go-version: 1.17
- name: Run unit Tests
run: |
go test -coverprofile=./cov.out ./...
- name: Run Gosec Security Scanner
run: |
go install github.com/securego/gosec/cmd/gosec@latest
gosec -no-fail -fmt=sonarqube -out report.json ./...
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

View File

@ -1,13 +1,23 @@
#!/bin/bash
echo 'Building functional-test binary'
go build
# reading os type from arguments
CURRENT_OS=$1
echo 'Building HTTPX binary from current branch'
go build -o httpx_dev ../httpx
if [ "${CURRENT_OS}" == "windows-latest" ];then
extension=.exe
fi
echo 'Installing latest release of HTTPX'
GO111MODULE=on go build -v github.com/projectdiscovery/httpx/cmd/httpx
echo "::group::Building functional-test binary"
go build -o functional-test$extension
echo "::endgroup::"
echo 'Starting HTTPX functional test'
./functional-test -main ./httpx -dev ./httpx_dev -testcases testcases.txt
echo "::group::Building dnsx binary from current branch"
go build -o httpx_dev$extension ../httpx
echo "::endgroup::"
echo "::group::Building latest release of dnsx"
go build -o httpx$extension -v github.com/projectdiscovery/httpx/cmd/httpx
echo "::endgroup::"
echo 'Starting dnsx functional test'
./functional-test$extension -main ./httpx$extension -dev ./httpx_dev$extension -testcases testcases.txt

View File

@ -1,13 +1,17 @@
#!/bin/bash
echo "::group::Build httpx"
rm integration-test httpx 2>/dev/null
cd ../cmd/httpx
go build
mv httpx ../../integration_tests/httpx
echo "::endgroup::"
echo "::group::Build httpx integration-test"
cd ../integration-test
go build
mv integration-test ../../integration_tests/integration-test
cd ../../integration_tests
echo "::endgroup::"
./integration-test
if [ $? -eq 0 ]
then

16
sonar-project.properties Normal file
View File

@ -0,0 +1,16 @@
sonar.projectKey=projectdiscovery_httpx
sonar.organization=projectdiscovery
# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=dnsx
#sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
sonar.sources=.
sonar.tests=.
sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=cov.out
sonar.externalIssuesReportPaths=report.json
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8