Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #361 from SegmentLinking/fix-ci
Browse files Browse the repository at this point in the history
Fix a few issues with the CI
  • Loading branch information
slava77 authored Jan 10, 2024
2 parents 130a14d + f7fb58a commit d0effe6
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 19 deletions.
29 changes: 18 additions & 11 deletions .github/workflows/static-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,42 @@ permissions:
jobs:
linter:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout PR
uses: actions/checkout@v4
- name: Mount cvmfs
uses: cvmfs-contrib/github-action-cvmfs@v3
- name: Gather paths of needed headers
shell: bash
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Generate compilation database
run: |
source setup.sh
INCLUDE_FLAGS="-I$TRACKLOOPERDIR -I$BOOST_ROOT/include -I$ALPAKA_ROOT/include -I$CUDA_HOME/include -I$ROOT_ROOT/include -I$CMSSW_BASE/src"
INCLUDE_FLAGS="$INCLUDE_FLAGS -I/cvmfs/cms.cern.ch/el8_amd64_gcc11/external/gcc/11.4.1-30ebdc301ebd200f2ae0e3d880258e65/include/c++/11.4.1"
INCLUDE_FLAGS="$INCLUDE_FLAGS -I/cvmfs/cms.cern.ch/el8_amd64_gcc11/external/gcc/11.4.1-30ebdc301ebd200f2ae0e3d880258e65/include/c++/11.4.1/x86_64-redhat-linux-gnu/"
INCLUDE_FLAGS="$INCLUDE_FLAGS -I/cvmfs/cms.cern.ch/el8_amd64_gcc11/external/gcc/11.4.1-30ebdc301ebd200f2ae0e3d880258e65/lib/gcc/x86_64-redhat-linux-gnu/11.4.1/include"
echo "include-flags=$INCLUDE_FLAGS" >> $GITHUB_ENV
# Note: Ideally we would use compiledb to generate a compile_commands.json file, but I couldn't get it to work properly with clang-tidy.
# This alternative of simply passing some extra arguments to clang-tidy seems to work fine (at least for now).
# There are some errors when running the script, but they don't affect anything important.
# We only need to run it to set up some environment variables, so we suppress the output.
source setup.sh 1> /dev/null 2> /dev/null
pip install compiledb compdb
cd SDL
make BACKEND=cpu explicit_cache -Bnwk > build_log.txt
compiledb < build_log.txt
# This extra step is needed to generate compilation commands for headers
compdb list > compile_commands_new.json
mv compile_commands_new.json compile_commands.json
- name: Run linter
uses: cpp-linter/cpp-linter-action@v2
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: 16
style: file
thread-comments: true
# only use checks in .clang-tidy file
tidy-checks: ''
lines-changed-only: true
ignore: .github|bin|code|data|efficiency
extra-args: '-ferror-limit=0 -std=c++17 -DALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED ${{ env.include-flags }}'
extra-args: '-U_OPENMP -ferror-limit=0'
- name: Fail job if there were checks that failed
if: steps.linter.outputs.checks-failed > 0
run: exit 1
95 changes: 87 additions & 8 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [created]

concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number }}
group: ${{ github.workflow }}-${{ github.event.issue.number }}-${{ contains(github.event.comment.body, '/run standalone') }}-${{ contains(github.event.comment.body, '/run cmssw') }}
cancel-in-progress: true

permissions:
Expand All @@ -20,11 +20,33 @@ jobs:
(github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'CONTRIBUTOR')
runs-on: ubuntu-latest
steps:
- name: Checkout PR
- name: Check out PR
uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Get commit SHA
run: |
sha=$(git rev-parse HEAD)
echo "COMMIT_SHA=$sha" >> $GITHUB_ENV
- name: Create App Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
skip-token-revoke: true
- name: Create in progress check
uses: LouisBrunner/[email protected]
with:
token: ${{ steps.app-token.outputs.token }}
sha: ${{ env.COMMIT_SHA }}
name: Run Standalone PU200
status: in_progress
details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
output: |
{"title": "This check has started...", "summary": "The logs can be found [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."}
- name: Build and run PR
timeout-minutes: 60
id: build-and-run
uses: SegmentLinking/TrackLooper-actions/standalone@v1
with:
Expand Down Expand Up @@ -56,8 +78,26 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `There was a problem while building and running in standalone mode. You can find a log of the job [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).`
body: `There was a problem while building and running in standalone mode. The logs can be found [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).`
})
- name: Create App Token
if: always()
uses: actions/create-github-app-token@v1
id: app-token-end
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Create completed check
uses: LouisBrunner/[email protected]
if: always()
with:
token: ${{ steps.app-token-end.outputs.token }}
sha: ${{ env.COMMIT_SHA }}
name: Run Standalone PU200
conclusion: ${{ job.status }}
details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
output: |
{"title": "Status: ${{ job.status }}", "summary": "The logs can be found [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."}
cmssw:
if: >
Expand All @@ -70,6 +110,27 @@ jobs:
uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Get commit SHA
run: |
sha=$(git rev-parse HEAD)
echo "COMMIT_SHA=$sha" >> $GITHUB_ENV
- name: Create App Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
skip-token-revoke: true
- name: Create in progress check
uses: LouisBrunner/[email protected]
with:
token: ${{ steps.app-token.outputs.token }}
sha: ${{ env.COMMIT_SHA }}
name: Run CMSSW 21034.1
status: in_progress
details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
output: |
{"title": "This check has started...", "summary": "The logs can be found [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."}
- name: Get CMSSW branch name
env:
COMMENT_BODY: ${{ github.event.comment.body }}
Expand All @@ -78,14 +139,13 @@ jobs:
cmssw_branch=
while IFS= read -r line; do
echo "$line"
if [[ $line == *"/run cmssw"* ]]; then
if [[ $line == "/run cmssw"* ]]; then
# Check if there is a branch after "/run cmssw"
words=($line)
cmssw_branch="${words[2]}"
# Validate the extracted branch to avoid code injection
if ! [[ $cmssw_branch =~ ^[[:alnum:]_-]+$ ]]; then
echo "Branch name is invalid. Ignoring..."
cmssw_branch=
if [ -n "$cmssw_branch" ]; then
cmssw_branch=$(git check-ref-format --branch $cmssw_branch || echo "default")
fi
fi
done <<< "$COMMENT_BODY"
Expand All @@ -95,6 +155,7 @@ jobs:
echo "Using CMSSW branch: $cmssw_branch"
echo "cmssw-branch=$cmssw_branch" >> $GITHUB_ENV
- name: Build and run PR
timeout-minutes: 200
id: build-and-run
uses: SegmentLinking/TrackLooper-actions/cmssw@v1
with:
Expand Down Expand Up @@ -127,5 +188,23 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `There was a problem while building and running with CMSSW. You can find a log of the job [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).`
body: `There was a problem while building and running with CMSSW. The logs can be found [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).`
})
- name: Create App Token
if: always()
uses: actions/create-github-app-token@v1
id: app-token-end
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Create completed check
uses: LouisBrunner/[email protected]
if: always()
with:
token: ${{ steps.app-token-end.outputs.token }}
sha: ${{ env.COMMIT_SHA }}
name: Run CMSSW 21034.1
conclusion: ${{ job.status }}
details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
output: |
{"title": "Status: ${{ job.status }}", "summary": "The logs can be found [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."}
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,14 @@ source $PWD/code/rooutil/thisrooutil.sh
# After this, you can compile and run LST as usual.
sdl_run -f -mc -s PU200 -n -1 -t myTag
```

## Code formatting and checking

The makefile in the `SDL` directory includes phony targets to run `clang-format` and `clang-tidy` on the code using the formatting and checks used in CMSSW. The following are the available commands.

- `make format`
Formats the code in the `SDL` directory using `clang-format` following the rules specified in `.clang-format`.
- `make check`
Runs `clang-tidy` on the code in the `SDL` directory to performs the checks specified in `.clang-tidy`.
- `make check-fix`
Same as `make check`, but fixes the issues that it knows how to fix.
16 changes: 16 additions & 0 deletions SDL/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,19 @@ clean:
rm -f *.so
rm -rf cpu/
rm -rf cuda/

.PHONY: clean explicit explicit_cache explicit_cache_cutvalue format check check-fix

format:
clang-format --style=file:../.clang-format -i *.cc *.h

# Collect all the include paths from the compiler.
# The .../gcc/x86_64-redhat-linux-gnu/*/include path is excluded since .../gcc/x86_64-redhat-linux-gnu/*/include-fixed should be used instead.
TIDYINCLUDEFLAGS := $(shell g++ -E -x c++ - -v < /dev/null 2>&1 | awk '/#include <...>/,/^End of search/{if (/^ / && !/x86_64-redhat-linux-gnu\/[0-9.]+\/include$$/) print "-I"$$1}' | tr '\n' ' ')
TIDYFLAGS := --language=c++ $(CXXFLAGS_CPU) $(ALPAKAINCLUDE) $(ALPAKASERIAL) $(ROOTCFLAGS) $(PRINTFLAG) $(DUPLICATED) $(CACHEFLAG_FLAGS) $(TIDYINCLUDEFLAGS)

check:
clang-tidy --config-file=../.clang-tidy *.cc *.h -- $(TIDYFLAGS)

check-fix:
clang-tidy --config-file=../.clang-tidy --format-style=file:../.clang-format --fix --fix-errors --fix-notes *.cc *.h -- $(TIDYFLAGS)

0 comments on commit d0effe6

Please sign in to comment.