Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh(ci): avoid to rerun veracode analyse on pr if it has already succeeded #2028

Merged
merged 3 commits into from
Jan 21, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/centreon-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
uses: ./.github/workflows/get-environment.yml
with:
version_file: CMakeLists.txt
nightly_manual_trigger: ${{ inputs.nightly_manual_trigger }}
nightly_manual_trigger: ${{ inputs.nightly_manual_trigger || false }}

unit-test:
needs: [get-environment]
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/gorgone-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: gorgone-analysis

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
workflow_dispatch:
inputs:
unit_tests:
description: 'Execute the unit tests'
required: true
default: true
type: boolean
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
paths:
- ".version"
- "gorgone/**"
- "perl-libs/**"
- "!gorgone/tests/**"
- "!gorgone/veracode.json"
- "!gorgone/.veracode-exclusions"
push:
branches:
- develop
- dev-[2-9][0-9].[0-9][0-9].x
- master
- "[2-9][0-9].[0-9][0-9].x"
paths:
- ".version"
- "gorgone/**"
- "perl-libs/**"
- "!gorgone/tests/**"
- "!gorgone/veracode.json"
- "!gorgone/.veracode-exclusions"

env:
base_directory: gorgone

jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
with:
version_file: gorgone/.version

veracode-analysis:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.is_targeting_feature_branch != 'true' &&
github.event.pull_request.draft != 'true'
uses: ./.github/workflows/veracode-analysis.yml
with:
module_directory: gorgone
module_name: centreon-gorgone
major_version: ${{ needs.get-environment.outputs.major_version }}
minor_version: ${{ needs.get-environment.outputs.minor_version }}
secrets:
veracode_api_id: ${{ secrets.VERACODE_API_ID_GORG }}
veracode_api_key: ${{ secrets.VERACODE_API_KEY_GORG }}
veracode_srcclr_token: ${{ secrets.VERACODE_SRCCLR_TOKEN }}

set-skip-label:
needs: [get-environment, veracode-analysis]
if: needs.get-environment.outputs.skip_workflow == 'false'
uses: ./.github/workflows/set-pull-request-skip-label.yml
22 changes: 0 additions & 22 deletions .github/workflows/gorgone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ concurrency:
on:
workflow_dispatch:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
paths:
- "gorgone/**"
- "!gorgone/tests/**"
Expand All @@ -38,23 +33,6 @@ jobs:
with:
version_file: gorgone/.version

veracode-analysis:
needs: [get-environment]
if: ${{ needs.get-environment.outputs.is_targeting_feature_branch != 'true' && github.event.pull_request.draft != 'true' }}
uses: ./.github/workflows/veracode-analysis.yml
with:
module_directory: gorgone
module_name: centreon-gorgone
major_version: ${{ needs.get-environment.outputs.major_version }}
minor_version: ${{ needs.get-environment.outputs.minor_version }}
img_version: ${{ needs.get-environment.outputs.img_version }}
secrets:
veracode_api_id: ${{ secrets.VERACODE_API_ID_GORG }}
veracode_api_key: ${{ secrets.VERACODE_API_KEY_GORG }}
veracode_srcclr_token: ${{ secrets.VERACODE_SRCCLR_TOKEN }}
docker_registry_id: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
docker_registry_passwd: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

package:
needs: [get-environment]
if: |
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/robot-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ jobs:
module_name: centreon-collect
major_version: ${{ needs.get-environment.outputs.major_version }}
minor_version: ${{ needs.get-environment.outputs.minor_version }}
img_version: ${{ needs.get-environment.outputs.img_version }}
secrets:
veracode_api_id: ${{ secrets.VERACODE_API_ID_COLL }}
veracode_api_key: ${{ secrets.VERACODE_API_KEY_COLL }}
veracode_srcclr_token: ${{ secrets.VERACODE_SRCCLR_TOKEN }}
docker_registry_id: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
docker_registry_passwd: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

package:
needs: [get-environment]
Expand Down
80 changes: 9 additions & 71 deletions .github/workflows/veracode-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@ on:
minor_version:
required: true
type: string
img_version:
required: true
type: string
secrets:
veracode_api_id:
required: true
veracode_api_key:
required: true
veracode_srcclr_token:
required: true
docker_registry_id:
required: true
docker_registry_passwd:
required: true

jobs:
routing:
Expand Down Expand Up @@ -62,60 +55,13 @@ jobs:

build:
name: Binary preparation
runs-on: [self-hosted, collect]
runs-on: [self-hosted, common]
needs: [routing]
if: needs.routing.outputs.skip_analysis == 'false'
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/centreon-collect-alma9:${{ inputs.img_version }}
credentials:
username: ${{ secrets.docker_registry_id }}
password: ${{ secrets.docker_registry_passwd }}

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- if: ${{ inputs.module_name == 'centreon-collect' }}
name: Compiling Cpp sources
run: |
rm -rf build
mkdir build
cd build

sudo pip3 install conan==1.57.0 --prefix=/usr --upgrade
sudo conan install .. -s compiler.cppstd=17 -s compiler.libcxx=libstdc++11 --build=missing

sudo cmake \
-G "Ninja" \
-DCMAKE_CXX_FLAGS="-gdwarf-2 -g3 -O0 -fno-builtin" \
-DWITH_TESTING=OFF \
-DWITH_BENCH=OFF \
-DWITH_MODULE_SIMU=OFF \
-DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_STARTUP_SCRIPT=systemd \
-DWITH_ENGINE_LOGROTATE_SCRIPT=ON \
-DWITH_USER_BROKER=centreon-broker \
-DWITH_GROUP_BROKER=centreon-broker \
-DWITH_USER_ENGINE=centreon-engine \
-DWITH_GROUP_ENGINE=centreon-engine \
-DWITH_VAR_DIR=/var/log/centreon-engine \
-DWITH_DAEMONS=ON \
-DWITH_CREATE_FILES=OFF \
-DWITH_CONFIG_FILES=ON \
..

sudo ninja

echo "[DEBUG] - Find compiled files"
find ./ -name "*.so"
echo "[DEBUG] - Build size"
du -sh ./lib/*.so | sort -rh

- if: ${{ inputs.module_name == 'centreon-collect' }}
name: Preserve centreon-collect binaries from cleaning
run: |
echo "[INFO] - Keeping only compiled files"
find build -type f -not \( -name "*.so" -or -name "cbd" -or -name "centengine" -or -name "cbwd" -or -name "centreon_connector_*" \) -delete

- name: Binary preparation of ${{ inputs.module_name }}
run: |
if [ -n "${{ inputs.module_directory }}" ]; then
Expand All @@ -141,25 +87,17 @@ jobs:
echo "::warning::No '.veracode-exclusions' file found for this module. Skipping exclusion step"
fi

if [ "${{ inputs.module_name }}" = "centreon-collect" ]; then
echo "[INFO] - Keeping only build's non empty folders"
find build -empty -type d -delete
ls -la build
echo "[INFO] - Generating the tarball"
tar cvzf "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.tar.gz" build
else
echo "[INFO] - Generating the zip"
zip -rq "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.zip" *
if [ -n "${{ inputs.module_directory }}" ]; then
cd -
mv ${{ inputs.module_directory }}/${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.zip .
fi
echo "[INFO] - Generating the zip"
zip -rq "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.zip" *
if [ -n "${{ inputs.module_directory }}" ]; then
cd -
mv ${{ inputs.module_directory }}/${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.zip .
fi

- name: Cache
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.${{ inputs.module_name == 'centreon-collect' && 'tar.gz' || 'zip' }}"
path: "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.zip"
key: "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary"

policy-scan:
Expand Down Expand Up @@ -189,7 +127,7 @@ jobs:
- name: Get build binary
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.${{ inputs.module_name == 'centreon-collect' && 'tar.gz' || 'zip' }}"
path: "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.zip"
key: "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary"

- name: Sandbox scan
Expand All @@ -198,7 +136,7 @@ jobs:
with:
appname: "${{ inputs.module_name }}"
version: "${{ inputs.major_version }}.${{ inputs.minor_version }}_runId-${{ github.run_id }}_attempt-${{ github.run_attempt }}"
filepath: "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.${{ inputs.module_name == 'centreon-collect' && 'tar.gz' || 'zip' }}"
filepath: "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.zip"
vid: "vera01ei-${{ secrets.veracode_api_id }}"
vkey: "vera01es-${{ secrets.veracode_api_key }}"
createprofile: true
Expand Down
Loading