Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Checkmarx One Containers-Resolver

on:
pull_request:

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up Go version
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: "go.mod"

- run: go version

- name: go test with coverage
run: |
go run gotest.tools/gotestsum@latest --format testdox -- -coverprofile=cover.out ./pkg/containerResolver...

- name: Check if total coverage is greater then 70
shell: bash
run: |
CODE_COV=$(go tool cover -func cover.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
EXPECTED_CODE_COV=70
var=$(awk 'BEGIN{ print "'$CODE_COV'"<"'$EXPECTED_CODE_COV'" }')
if [ "$var" -eq 1 ];then
echo "Your code coverage is too low. Coverage precentage is: $CODE_COV"
exit 1
else
echo "Your code coverage test passed! Coverage precentage is: $CODE_COV"
exit 0
fi
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release Containers resolver Go module new version

on:
pull_request:
types:
- closed
branches:
- main

jobs:
tag-and-release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Get and Format the PR Title
id: get_pr_title
run: |
pr_title="${{ github.event.pull_request.title }}"
# Use grep with regex to extract the format (AST-000) from the title
formatted_title=$(echo "$pr_title" | grep -oE "\(AST-[0-9]+\)")
# If formatted_title is empty, set a default value or handle the error
if [ -z "$formatted_title" ]; then
echo "No valid format found in PR title."
exit 1
fi
echo "formatted_title=$formatted_title" >> $GITHUB_ENV

- name: Fetch All Tags
run: git fetch --tags

- name: Get Latest Tag
id: get_tag
run: |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "tag=${latest_tag}" >> $GITHUB_ENV

- name: Bump Patch Version
id: bump
uses: cbrgm/semver-bump-action@v1.0.30
with:
current-version: ${{ env.tag }}
bump-level: patch

- name: Create a new tag
run: |
new_tag=${{ steps.bump.outputs.new_version }}
git tag $new_tag -m "${{ env.formatted_title }}"
git push origin $new_tag

- name: Create release from tag
uses: actions/create-release@v1
with:
tag_name: ${{ steps.bump.outputs.new_version }}
release_name: Release ${{ steps.bump.outputs.new_version }}
body: ${{ steps.get_pr_title.outputs.pr_title }}
draft: false
prerelease: false
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23.3

require (
github.com/Checkmarx/containers-images-extractor v1.0.3
github.com/Checkmarx/containers-syft-packages-extractor v1.0.5
github.com/Checkmarx/containers-syft-packages-extractor v1.0.6-0.20250130183701-3874a3497983
github.com/Checkmarx/containers-types v1.0.0
github.com/rs/zerolog v1.33.0
github.com/stretchr/testify v1.10.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Checkmarx/containers-images-extractor v1.0.3 h1:v/F9PxR0YxVHY5I3mizgpBhARQXKFVwDsNz/d8AKQow=
github.com/Checkmarx/containers-images-extractor v1.0.3/go.mod h1:cHtEnS5wlG7bTImOkhTjyZQ9mRurNLWPbnVqmQl94dk=
github.com/Checkmarx/containers-syft-packages-extractor v1.0.5 h1:wFrO/bx+tyldwnCQEujoHd1WyVzeJJkVovCBhIq4h5s=
github.com/Checkmarx/containers-syft-packages-extractor v1.0.5/go.mod h1:a2Qdlu/FAhptH8u+flWUAodc15JSeQFvIshs9RmIRJU=
github.com/Checkmarx/containers-syft-packages-extractor v1.0.6-0.20250130183701-3874a3497983 h1:jPFfsFsfCx9NPKTskVkzW1XZCkE9ISSpJ4Dd+hddKgM=
github.com/Checkmarx/containers-syft-packages-extractor v1.0.6-0.20250130183701-3874a3497983/go.mod h1:cYpRbQpG/7zSC+NCnKbm3omFpP2dNJ4FFUwVPJmrtsU=
github.com/Checkmarx/containers-types v1.0.0 h1:H3bAbFnb4GqrAuYww63Ts1S3XmiLt+m8aqLuL/D9pz8=
github.com/Checkmarx/containers-types v1.0.0/go.mod h1:yp956K0amnEYogUnVOjuVTe1euNr/0qkgB+NhaqW4M8=
github.com/CycloneDX/cyclonedx-go v0.9.2 h1:688QHn2X/5nRezKe2ueIVCt+NRqf7fl3AVQk+vaFcIo=
Expand Down
Loading