Skip to content

Commit

Permalink
add CI tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxtof committed Mar 21, 2023
1 parent f2d7546 commit 8c54f6d
Show file tree
Hide file tree
Showing 15 changed files with 382 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Bug report
about: Tell us about a problem you are experiencing

---

/kind bug

**What steps did you take and what happened:**

_A clear and concise description of what the bug is and how has this been tested. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration_


**What did you expect to happen:**


**Anything else you would like to add:**

_Miscellaneous information that will assist in solving the issue._


**Environment:**

- Nutanix objects version:
- Nutanix COSI version:
- Kubernetes version: (use `kubectl version`):
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Feature enhancement request
about: Suggest an idea for this project

---

/kind feature

**Describe the solution you'd like**
[A clear and concise description of what you want to happen.]


**Anything else you would like to add:**
[Miscellaneous information that will assist in solving the issue.]


**Environment:**

- Nutanix objects version:
- Nutanix COSI version:
- Kubernetes version: (use `kubectl version`):
30 changes: 30 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!-- Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, read our contributor guidelines https://github.com/nutanix-cloud-native/cluster-api-provider-nutanix/blob/main/CONTRIBUTING.md and developer guide https://git.k8s.io/community/contributors/devel/development.md#development-guide
2. If you want *faster* PR reviews, read how: https://git.k8s.io/community/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
3. Follow the instructions for writing a release note: https://git.k8s.io/community/contributors/guide/release-notes.md
4. If the PR is unfinished, see how to mark it: https://git.k8s.io/community/contributors/guide/pull-requests.md#marking-unfinished-pull-requests
5. If this PR changes image versions, please title this PR "Bump <image name> from x.x.x to y.y.y."
-->

**What this PR does / why we need it**:

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**How Has This Been Tested?**:

_Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and test output_


**Special notes for your reviewer**:

_Please confirm that if this PR changes any image versions, then that's the sole change this PR makes._

**Release note**:
<!-- Write your release note:
1. Enter your extended release note in the below block. If the PR requires additional action from users switching to the new release, include the string "action required".
2. If no release note is required, just write "NONE".
-->
```release-note
```
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# Enable version updates for Go modules
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"

# Enable version updates for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
24 changes: 24 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .github/release.yml

changelog:
exclude:
labels:
- ignore-for-release
categories:
- title: Breaking Changes 🛠
labels:
- Semver-Major
- breaking-change
- title: Exciting New Features 🎉
labels:
- Semver-Minor
- enhancement
- title: Bug Fixes 🐛
labels:
- bug
- title: Documentation 📖
labels:
- documentation
- title: Other Changes
labels:
- "*"
35 changes: 35 additions & 0 deletions .github/workflows/build-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test Build
env:
EXPORT_RESULT: true
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-container:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."

- name: Checkout
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "^1.19"

- name: Test build
run: make build

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.9.2
with:
scan-type: "fs"
ignore-unfixed: true
format: "table"
exit-code: "1"
vuln-type: "os,library"
severity: "CRITICAL,HIGH"
51 changes: 51 additions & 0 deletions .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "Code Scanning - Action"

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '30 1 * * 0'

jobs:
CodeQL-Build:
runs-on: ubuntu-latest

permissions:
# required for all workflows
security-events: write

# only required for workflows in private repositories
actions: read
contents: read

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, 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.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your
# project uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
60 changes: 60 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Generate release artefact

on:
push:
tags:
- "v*.*.*"

jobs:
build_release:
name: Build Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get repository name
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "^1.19"

- name: Install tools
uses: redhat-actions/openshift-tools-installer@v1
with:
source: "github"
kustomize: "latest"
ko: "latest"

- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: capi-nutanix
sep-tags: ","
sep-labels: ","
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=sha
- name: Build container
env:
KO_DOCKER_REPO: ghcr.io/${{ github.repository }}
TAGS: ${{ steps.meta.outputs.tags }}
LABELS: ${{ steps.meta.outputs.labels }}
PLATFORMS: linux/amd64,linux/arm64,linux/arm
run: |
PTAGS=`echo $TAGS | sed 's/capi-nutanix://g'`
export SOURCE_DATE_EPOCH=$(date +%s)
ko build --bare --image-label "$LABELS" -t "$PTAGS" --platform=$PLATFORMS ./cmd/${{ env.REPOSITORY_NAME }}
29 changes: 29 additions & 0 deletions .github/workflows/synopsys-schedule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Black Duck Intelligent Policy Check
on:
schedule:
- cron: "0 0 * * *"

jobs:
security:
if: github.repository == 'nutanix-cloud-native/cosi-driver-nutanix'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "^1.19"

- name: Build Project
run: make build

- name: Run Synopsys Detect
uses: synopsys-sig/detect-action@v0.3.4
with:
scan-mode: INTELLIGENT
github-token: ${{ secrets.GITHUB_TOKEN }}
detect-version: 7.9.0
blackduck-url: ${{ secrets.BLACKDUCK_URL }}
blackduck-api-token: ${{ secrets.BLACKDUCK_API_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/synopsys.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Black Duck Policy Check
on:
pull_request:
branches:
- main
push:

jobs:
security:
if: github.repository == 'nutanix-cloud-native/cosi-driver-nutanix'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "^1.19"

- name: Build Project
run: make build

- name: Run Synopsys Detect
uses: synopsys-sig/detect-action@v0.3.4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
detect-version: 7.9.0
blackduck-url: ${{ secrets.BLACKDUCK_URL }}
blackduck-api-token: ${{ secrets.BLACKDUCK_API_TOKEN }}
56 changes: 56 additions & 0 deletions .github/workflows/trivy-scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Trivy Scan

on:
workflow_dispatch:
schedule:
- cron: "17 17 * * *"

permissions:
contents: read

jobs:
build:
permissions:
contents: read
security-events: write
name: Scan
runs-on: "ubuntu-latest"
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Get repository name
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "^1.19"

- name: Install tools
uses: redhat-actions/openshift-tools-installer@v1
with:
source: "github"
kustomize: "latest"
ko: "latest"

- name: Build container
env:
KO_DOCKER_REPO: ko.local
PLATFORMS: linux/amd64,linux/arm64,linux/arm
run: |
export SOURCE_DATE_EPOCH=$(date +%s)
ko build -B -t ${{ github.sha }} --platform=$PLATFORMS ./cmd/${{ env.REPOSITORY_NAME }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.9.2
with:
image-ref: "ko.local/${{ env.REPOSITORY_NAME }}:${{ github.sha }}"
format: "sarif"
output: "trivy-results.sarif"
severity: "CRITICAL,HIGH"

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results.sarif"
Loading

0 comments on commit 8c54f6d

Please sign in to comment.