Skip to content

use ct to run tests #146

use ct to run tests

use ct to run tests #146

Workflow file for this run

name: lint
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
# https://github.com/bridgecrewio/checkov-action#example-usage-for-iac-and-sca
checkov:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so follow-up steps can access it
- uses: actions/checkout@v3
- name: Checkov GitHub Action
uses: bridgecrewio/checkov-action@v12
with:
# This will add both a CLI output to the console and create a results.sarif file
output_format: cli,sarif
output_file_path: console,results.sarif
framework: github_actions
directory: .github
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
# Results are generated only on a success or failure
# this is required since GitHub by default won't run the next step
# when the previous one has failed. Security checks that do not pass will 'fail'.
# An alternative is to add `continue-on-error: true` to the previous step
# Or 'soft_fail: true' to checkov.
if: success() || failure()
with:
sarif_file: results.sarif
# https://github.com/helm/chart-testing-action#example-workflow
ct-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Set up chart-testing
uses: helm/chart-testing-action@v2
- name: Override ct version
uses: ./.github/actions/setup-chart-testing
with:
url: https://github.com/jouve/chart-testing
version: 3.10.0
- name: Setup kube-linter
uses: ./.github/actions/setup-kube-linter
- name: Setup helm unittest
uses: ./.github/actions/setup-helm-plugin
with:
url: https://github.com/helm-unittest/helm-unittest.git
version: v0.3.5
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct --config .ct/ct.yaml list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct --config .ct/ct.yaml lint --target-branch ${{ github.event.repository.default_branch }}
# https://github.com/aquasecurity/trivy-action#scan-ci-pipeline-w-trivy-config
trivy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run Trivy vulnerability scanner in fs mode
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
trivy-config: trivy.yaml