Skip to content

Commit

Permalink
Adding SonarCloud analyzis
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrt committed Dec 5, 2020
1 parent 7f8e30f commit 8c9fe7d
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 0 deletions.
119 changes: 119 additions & 0 deletions .github/workflows/build_pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: EC2Cryptomatic build and deployment

on:
- push
- pull_request

jobs:

code_linting:
runs-on: ubuntu-latest
container:
image: cytopia/golint:latest
volumes:
- /__w/ec2cryptomatic/ec2cryptomatic:/data

steps:
- uses: actions/checkout@v2
- name: Starting code linting
run: golint .


code_testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0

- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: '^1.14' # The Go version to download (if necessary) and use.

- name: Run Golang test
run: go test .

- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Create Docker image file
run: docker build .


code_compiling:
needs: [code_linting, code_testing]
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, windows, freebsd]
arch: [amd64, arm]
exclude:
- os: windows
arch: arm
fail-fast: true

steps:
- uses: actions/checkout@v2

- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: '^1.14' # The Go version to download (if necessary) and use.

- run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o ec2cryptomatic

- name: Package artefacts
run: zip ec2cryptomatic.${{ matrix.os }}.${{ matrix.arch }}.zip ec2cryptomatic

- uses: actions/upload-artifact@v2
with:
path: ec2cryptomatic.${{ matrix.os }}.${{ matrix.arch }}.zip


code_deploying:
needs: [code_linting, code_testing, code_compiling]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/feature/improving_github_actions_wf'
steps:
- uses: actions/checkout@v2
- name: Set VERSION variable
id: vars
run: echo ::set-output name=tag_version::"$(head -1 VERSION)"

- name: Download artefacts before uploading
uses: actions/download-artifact@v2

- name: Create a new release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.vars.outputs.tag_version }}
release_name: Release ${{ steps.vars.outputs.tag_version }}
draft: false
prerelease: false

- name: Upload Release Assets
id: upload-release-assets
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
assets_path: artifact/

- name: Publish image to Registry with tag of the current version
uses: elgohr/[email protected]
with:
name: jbrt/ec2cryptomatic
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: Dockerfile
tags: "latest,${{ steps.vars.outputs.tag_version }}"

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Github Action](https://github.com/jbrt/ec2cryptomatic/workflows/publish-docker-image/badge.svg)](https://github.com/jbrt/ec2cryptomatic/actions?workflow=publish-docker-image)
![Docker Pulls](https://img.shields.io/docker/pulls/jbrt/ec2cryptomatic.svg?label=pulls&logo=docker)
[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=jbrt_ec2cryptomatic)](https://sonarcloud.io/dashboard?id=jbrt_ec2cryptomatic)

Encrypt EBS volumes from AWS EC2 instances

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.2.3
6 changes: 6 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sonar.organization=jbrt
sonar.projectKey=jbrt_ec2cryptomatic

# relative paths to source directories. More details and properties are described
# in https://sonarcloud.io/documentation/project-administration/narrowing-the-focus/
sonar.sources=.

0 comments on commit 8c9fe7d

Please sign in to comment.