Skip to content

Commit

Permalink
Merge branch 'anchore:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gaevans-ebay authored Apr 11, 2024
2 parents ddd080f + 2baea4f commit 523498c
Show file tree
Hide file tree
Showing 197 changed files with 26,135 additions and 1,004 deletions.
33 changes: 31 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@ on:
push:
branches:
- main
- 'release-*'
paths:
- 'stable/**'

permissions:
contents: read

jobs:
release:
permissions:
contents: write # for helm/chart-releaser-action to push chart release and create a release
env:
REPO: "${{ github.repository }}"
REPO_NAME: "${{ github.event.repository.name }}"
TARGET_BRANCH: "${{ github.event.pull_request.base.ref }}"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0

- name: Fetch history
run: git fetch --prune --unshallow
Expand All @@ -20,8 +32,25 @@ jobs:
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Add Anchore Helm repo
run: |
helm repo add anchore https://charts.anchore.io/stable
helm repo add bitnami https://charts.bitnami.com/bitnami
- name: Run chart-releaser not latest
if: github.event.pull_request.base.ref != 'main'
uses: helm/chart-releaser-action@a917fd15b20e8b64b94d9158ad54cd6345335584 # v1.6.0
with:
charts_dir: stable
charts_repo_url: https://charts.anchore.io
mark_as_latest: false
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_MAKE_RELEASE_LATEST: "false"

- name: Run chart-releaser
uses: helm/[email protected]
if: github.event.pull_request.base.ref == 'main'
uses: helm/chart-releaser-action@a917fd15b20e8b64b94d9158ad54cd6345335584 # v1.6.0
with:
charts_dir: stable
charts_repo_url: https://charts.anchore.io
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/helm-unittests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright VMware, Inc.
# SPDX-License-Identifier: APACHE-2.0

name: 'Helm Unit Tests'

on:
pull_request:
paths:
- 'stable/enterprise/Chart.yaml'
- 'stable/feeds/Chart.yaml'

# Remove all permissions by default
permissions: {}
jobs:
helm-unittests:
permissions:
contents: read # for helm-unittest to read the chart
env:
REPO: "${{ github.repository }}"
REPO_NAME: "${{ github.event.repository.name }}"
TARGET_BRANCH: "${{ github.event.pull_request.base.ref }}"
HELM_UNITTEST_VERSION: 0.3.5
runs-on: ubuntu-latest
steps:
- name: Checkout charts
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
path: ${{ github.repository }}
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
with:
version: v3.8.0

- name: Install helm-unittest
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest.git --version ${HELM_UNITTEST_VERSION}
- run: cd "${REPO}" && git fetch origin ${TARGET_BRANCH}

- name: Execute helm-unittests
run: |
cd "${REPO}"
files_changed="$(git diff --name-only origin/${TARGET_BRANCH} | sort | uniq)"
# Adding || true to avoid "Process exited with code 1" errors
charts_dirs_changed="$(echo "$files_changed" | xargs dirname | grep -o "stable/[^/]*" | sort | uniq || true)"
for chart in ${charts_dirs_changed}; do
echo "running helm unittest . for ${chart}"
pushd "${chart}"
helm repo add anchore https://charts.anchore.io/stable
helm dep up
helm unittest .
popd
done
45 changes: 45 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Lint changed charts using chart-testing tool"

on:
pull_request:
paths:
- 'stable/**'

permissions:
contents: read

jobs:
lint:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0

- name: Fetch history
run: git fetch --prune --unshallow

- name: Shellcheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0

- name: Set up chart-testing
uses: helm/chart-testing-action@b43128a8b25298e1e7b043b78ea6613844e079b1 # v2.7.0

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config 'ct-config.yaml' --target-branch ${{ github.event.pull_request.base.ref }})
if [[ -n "$changed" ]]; then
echo "CHANGED=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
id: lint
run: ct lint --config 'ct-config.yaml'
if: steps.list-changed.outputs.CHANGED == 'true' && github.event.pull_request.base.ref == 'main'

- name: Run chart-testing but skip version check (lint)
id: lintskipversion
run: ct lint --config 'ct-config.yaml' --check-version-increment=false
if: steps.list-changed.outputs.CHANGED == 'true' && github.event.pull_request.base.ref != 'main'
71 changes: 71 additions & 0 deletions .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '20 7 * * 2'
push:
branches: ["main"]

# Declare default permissions as read only.
permissions: read-all

jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
contents: read
actions: read

steps:
- name: "Checkout code"
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # v2.0.6
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecards on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}

# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@04daf014b50eaf774287bf3f0f1869d4b4c4b913 # v2.21.7
with:
sarif_file: results.sarif
87 changes: 72 additions & 15 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,102 @@
name: "Test using kind and chart-testing tool"

on:
- pull_request
pull_request:
paths:
- 'stable/**'

permissions:
contents: read

jobs:
test:
strategy:
fail-fast: false
matrix:
kubernetesVersion: ["v1.14.10", "v1.22.0"]
kubernetesVersion: ["v1.24.17", "v1.25.16", "v1.26.14", "v1.27.11", "v1.28.7", "v1.29.2"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0

- name: Fetch history
run: git fetch --prune --unshallow

- name: Shellcheck
uses: ludeeus/[email protected]
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0

- uses: actions/setup-python@e9aba2c848f5ebd159c070c61ea2c4e2b122355e # v2.3.4
with:
python-version: 3.7

- name: Set up Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
with:
version: v3.8.0

- name: Set up chart-testing
uses: helm/chart-testing-action@b43128a8b25298e1e7b043b78ea6613844e079b1 # v2.7.0

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config 'ct-config.yaml' --target-branch ${{ github.event.pull_request.base.ref }})
if [[ -n "$changed" ]]; then
echo "CHANGED=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
id: lint
uses: helm/[email protected]
with:
command: lint
config: ct-config.yaml
run: ct lint --config 'ct-config.yaml'
if: steps.list-changed.outputs.CHANGED == 'true' && github.event.pull_request.base.ref == 'main'

- name: Run chart-testing but skip version check (lint)
id: lintskipversion
run: ct lint --config 'ct-config.yaml' --check-version-increment=false
if: steps.list-changed.outputs.CHANGED == 'true' && github.event.pull_request.base.ref != 'main'

- name: Install kind
uses: helm/[email protected]
if: steps.list-changed.outputs.CHANGED == 'true'
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0
with:
node_image: "kindest/node:${{ matrix.kubernetesVersion }}"
config: kind-config.yaml
wait: 600s
if: steps.lint.outputs.changed == 'true'

- name: Check kind nodes
if: steps.list-changed.outputs.CHANGED == 'true'
run: kubectl describe nodes

- name: Run chart-testing (install)
uses: helm/[email protected]
with:
command: install
config: ct-config.yaml
- name: Create pullcreds and license secrets
if: steps.list-changed.outputs.CHANGED == 'true'
run: |
kubectl create namespace anchore
echo "${ANCHORE_LICENSE}" | base64 --decode > /tmp/anchore-license
kubectl --namespace anchore create secret generic anchore-enterprise-license --from-file=license.yaml=/tmp/anchore-license
kubectl --namespace anchore create secret docker-registry anchore-enterprise-pullcreds --docker-server=docker.io --docker-username="${DOCKER_USER}" --docker-password="${DOCKER_PASS}"
env:
ANCHORE_LICENSE: ${{ secrets.B64_ANCHORE_LICENSE }}
DOCKER_USER: ${{ secrets.ANCHOREREADONLY_DH_USERNAME }}
DOCKER_PASS: ${{ secrets.ANCHOREREADONLY_DH_PAT }}

- name: Check if anchore-engine endpoint is required for admission controller chart
id: engine_required
run: |
if [[ -n $(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep 'anchore-admission-controller') ]]; then
echo "File in the 'stable/anchore-admission-controller' directory was changed. We need an engine deployment"
echo "::set-output name=changed::true"
else
echo "No files in 'stable/anchore-admission-controller' directory were changed. Skipping engine deployment"
echo "::set-output name=changed::false"
fi
shell: bash

- name: Deploy Engine
if: steps.engine_required.outputs.changed == 'true'
run: |
helm install engine anchore/anchore-engine --namespace anchore --wait
kubectl --namespace anchore get pods
- name: Run chart-testing
if: steps.list-changed.outputs.CHANGED == 'true'
run: ct install --config ct-config.yaml --helm-extra-args "--timeout 600s"
34 changes: 34 additions & 0 deletions .github/workflows/values-converter-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build & push values converter docker image

on:
push:
branches:
- main
paths:
- 'scripts/enterprise-value-converter/**'

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

- name: Login to DockerHub
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
username: ${{ secrets.ANCHOREDEVWRITE_DH_USERNAME }}
password: ${{ secrets.ANCHOREDEVWRITE_DH_PAT }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: "{{defaultContext}}:scripts/enterprise-value-converter"
push: true
tags: |
anchore/enterprise-helm-migrator:${{ github.sha }}
anchore/enterprise-helm-migrator:latest
Loading

0 comments on commit 523498c

Please sign in to comment.