Skip to content

Commit f0fb54d

Browse files
Merge pull request #1 from Checkmarx/alex-fix-temp-cleanup
Alex fix temp cleanup and workflows
2 parents a6a4882 + ba2ae9f commit f0fb54d

File tree

4 files changed

+99
-3
lines changed

4 files changed

+99
-3
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Checkmarx One Containers-Resolver
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
unit-tests:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout the repository
11+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
12+
13+
- name: Set up Go version
14+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
15+
with:
16+
go-version-file: "go.mod"
17+
18+
- run: go version
19+
20+
- name: go test with coverage
21+
run: |
22+
go run gotest.tools/gotestsum@latest --format testdox -- -coverprofile=cover.out ./pkg/containerResolver...
23+
24+
- name: Check if total coverage is greater then 70
25+
shell: bash
26+
run: |
27+
CODE_COV=$(go tool cover -func cover.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
28+
EXPECTED_CODE_COV=70
29+
var=$(awk 'BEGIN{ print "'$CODE_COV'"<"'$EXPECTED_CODE_COV'" }')
30+
if [ "$var" -eq 1 ];then
31+
echo "Your code coverage is too low. Coverage precentage is: $CODE_COV"
32+
exit 1
33+
else
34+
echo "Your code coverage test passed! Coverage precentage is: $CODE_COV"
35+
exit 0
36+
fi

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Release Containers resolver Go module new version
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- main
9+
10+
jobs:
11+
tag-and-release:
12+
if: github.event.pull_request.merged == true
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout the repository
16+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
17+
18+
- name: Get and Format the PR Title
19+
id: get_pr_title
20+
run: |
21+
pr_title="${{ github.event.pull_request.title }}"
22+
# Use grep with regex to extract the format (AST-000) from the title
23+
formatted_title=$(echo "$pr_title" | grep -oE "\(AST-[0-9]+\)")
24+
# If formatted_title is empty, set a default value or handle the error
25+
if [ -z "$formatted_title" ]; then
26+
echo "No valid format found in PR title."
27+
exit 1
28+
fi
29+
echo "formatted_title=$formatted_title" >> $GITHUB_ENV
30+
31+
- name: Fetch All Tags
32+
run: git fetch --tags
33+
34+
- name: Get Latest Tag
35+
id: get_tag
36+
run: |
37+
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
38+
echo "tag=${latest_tag}" >> $GITHUB_ENV
39+
40+
- name: Bump Patch Version
41+
id: bump
42+
uses: cbrgm/[email protected]
43+
with:
44+
current-version: ${{ env.tag }}
45+
bump-level: patch
46+
47+
- name: Create a new tag
48+
run: |
49+
new_tag=${{ steps.bump.outputs.new_version }}
50+
git tag $new_tag -m "${{ env.formatted_title }}"
51+
git push origin $new_tag
52+
53+
- name: Create release from tag
54+
uses: actions/create-release@v1
55+
with:
56+
tag_name: ${{ steps.bump.outputs.new_version }}
57+
release_name: Release ${{ steps.bump.outputs.new_version }}
58+
body: ${{ steps.get_pr_title.outputs.pr_title }}
59+
draft: false
60+
prerelease: false

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.23.3
44

55
require (
66
github.com/Checkmarx/containers-images-extractor v1.0.3
7-
github.com/Checkmarx/containers-syft-packages-extractor v1.0.5
7+
github.com/Checkmarx/containers-syft-packages-extractor v1.0.6-0.20250130183701-3874a3497983
88
github.com/Checkmarx/containers-types v1.0.0
99
github.com/rs/zerolog v1.33.0
1010
github.com/stretchr/testify v1.10.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2
6363
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
6464
github.com/Checkmarx/containers-images-extractor v1.0.3 h1:v/F9PxR0YxVHY5I3mizgpBhARQXKFVwDsNz/d8AKQow=
6565
github.com/Checkmarx/containers-images-extractor v1.0.3/go.mod h1:cHtEnS5wlG7bTImOkhTjyZQ9mRurNLWPbnVqmQl94dk=
66-
github.com/Checkmarx/containers-syft-packages-extractor v1.0.5 h1:wFrO/bx+tyldwnCQEujoHd1WyVzeJJkVovCBhIq4h5s=
67-
github.com/Checkmarx/containers-syft-packages-extractor v1.0.5/go.mod h1:a2Qdlu/FAhptH8u+flWUAodc15JSeQFvIshs9RmIRJU=
66+
github.com/Checkmarx/containers-syft-packages-extractor v1.0.6-0.20250130183701-3874a3497983 h1:jPFfsFsfCx9NPKTskVkzW1XZCkE9ISSpJ4Dd+hddKgM=
67+
github.com/Checkmarx/containers-syft-packages-extractor v1.0.6-0.20250130183701-3874a3497983/go.mod h1:cYpRbQpG/7zSC+NCnKbm3omFpP2dNJ4FFUwVPJmrtsU=
6868
github.com/Checkmarx/containers-types v1.0.0 h1:H3bAbFnb4GqrAuYww63Ts1S3XmiLt+m8aqLuL/D9pz8=
6969
github.com/Checkmarx/containers-types v1.0.0/go.mod h1:yp956K0amnEYogUnVOjuVTe1euNr/0qkgB+NhaqW4M8=
7070
github.com/CycloneDX/cyclonedx-go v0.9.2 h1:688QHn2X/5nRezKe2ueIVCt+NRqf7fl3AVQk+vaFcIo=

0 commit comments

Comments
 (0)