Skip to content

Commit

Permalink
Merge branch 'main' into jupyter
Browse files Browse the repository at this point in the history
  • Loading branch information
AJPfleger authored Jun 22, 2024
2 parents 03dc02e + 5ecd0ac commit e0d23c0
Show file tree
Hide file tree
Showing 141 changed files with 2,338 additions and 1,955 deletions.
37 changes: 29 additions & 8 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ concurrency:
env:
CTEST_OUTPUT_ON_FAILURE: 1
CCACHE_DIR: ${{ github.workspace }}/ccache
CCACHE_MAXSIZE: 500M
CCACHE_MAXSIZE: 1.25G
CCACHE_KEY_SUFFIX: r1
ACTS_LOG_FAILURE_THRESHOLD: WARNING

Expand All @@ -31,6 +31,7 @@ jobs:
runs-on: ubuntu-latest
container: ghcr.io/acts-project/ubuntu2204:v41
steps:

- uses: actions/checkout@v4

- name: Cache build
Expand All @@ -50,13 +51,23 @@ jobs:
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_CXX_FLAGS="-Werror -gz -g1"
-DACTS_BUILD_UNITTESTS=on
-DACTS_BUILD_EXAMPLES_UNITTESTS=off
-DACTS_BUILD_EVERYTHING=ON
-DACTS_BUILD_ODD=OFF
-DACTS_BUILD_EXAMPLES_PYTHON_BINDINGS=ON
-DACTS_BUILD_EXAMPLES_EDM4HEP=ON
-DACTS_BUILD_ANALYSIS_APPS=ON
-DACTS_BUILD_PLUGIN_ONNX=ON
-DACTS_BUILD_PLUGIN_ACTSVG=ON
-DACTS_ENABLE_LOG_FAILURE_THRESHOLD=ON
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Build
run: cmake --build build
- name: ccache stats
run: ccache -s
- name: Unit tests
run: cmake --build build --target test
run: ctest --test-dir build -j$(nproc)

- name: Remove .o files
run: >
du -sh build
Expand All @@ -67,12 +78,22 @@ jobs:
pip3 install gcovr==7.2
&& cd build
&& /usr/bin/python3 ../CI/test_coverage.py
- name: Upload coverage
uses: codecov/codecov-action@v4
- uses: actions/upload-artifact@v4
with:
name: coverage-build
path: build

- name: Save PR number to file
if: github.event_name == 'pull_request'
run: echo ${{ github.event.number }} > PR_NUMBER.txt

- name: Persist PR number
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
files: ./build/coverage/cov.xml
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }} # required
name: PR_NUMBER
path: PR_NUMBER.txt

build_performance:
runs-on: ubuntu-latest
Expand All @@ -81,7 +102,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: pip3 install git+https://github.com/paulgessinger/cmakeperf.git@ece8fc8
run: pip3 install git+https://github.com/paulgessinger/cmakeperf.git@2a409b5
- name: Configure
run: >
cmake -B build -S .
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
- name: Check
run: >
CI/check_end_of_file.py . --exclude "thirdparty/*" --reject-multiple-newlines --github
size_t:
type_t:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -86,7 +86,7 @@ jobs:
python-version: '3.12'
- name: Check
run: >
CI/check_size_t.py . --exclude "thirdparty/*"
CI/check_type_t.py . --exclude "thirdparty/*"
boost_test_macro:
runs-on: ubuntu-latest
steps:
Expand Down
141 changes: 141 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: SonarCloud
on:
workflow_run:
workflows: [Analysis]
types: [completed]

jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
container: ghcr.io/acts-project/ubuntu2204:v41
if: github.event.workflow_run.conclusion == 'success' && github.repository == "acts-project"
steps:
- name: Dump job context
env:
PAYLOAD: ${{ toJson(github.event.workflow_run) }}
run: echo "${PAYLOAD}"

- name: Install dependencies
run: |
apt-get update
apt-get install -y unzip
- name: "Checkout repository"
uses: actions/checkout@v4

- name: 'Download artifact'
uses: actions/github-script@v7
id: dl-af
with:
script: |
console.log(`Getting artifacts for workflow run id: ${context.payload.workflow_run.id}`);
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
for (artifact of allArtifacts.data.artifacts) {
console.log(`Artifact #${artifact.id} ${artifact.name}`);
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${artifact.name}.zip`, Buffer.from(download.data));
}
return true;
- name: Unzip coverage build
run: unzip coverage-build.zip -d build

- name: Unzip PR_NUMBER
if: github.event.workflow_run.event == 'pull_request'
run: unzip PR_NUMBER.zip

- name: Debug
run: |
ls -al
ls -al build
ls -al build/coverage
- name: Read PR_NUMBER.txt
if: github.event.workflow_run.event == 'pull_request'
id: pr_number
uses: juliangruber/read-file-action@v1
with:
path: ./PR_NUMBER.txt

- name: Request GitHub API for PR data
if: github.event.workflow_run.event == 'pull_request'
uses: octokit/[email protected]
id: get_pr_data
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: GET /repos/{full_name}/pulls/{number}
number: ${{ steps.pr_number.outputs.content }}
full_name: ${{ github.event.repository.full_name }}

- name: Get upcoming version from milestones
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: acts-project/acts
run: |
CI/get_next_milestone.py | tee next_version.txt
- name: Read next_version.txt
id: next_version
uses: juliangruber/read-file-action@v1
with:
path: ./next_version.txt

- name: Checkout base branch
if: github.event.workflow_run.event == 'pull_request'
run: |
git config --global --add safe.directory $PWD
git remote rename origin upstream
git checkout -B ${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} upstream/${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
git remote add origin ${{ fromJson(steps.get_pr_data.outputs.data).head.repo.clone_url }}
git fetch origin
git checkout ${{ fromJson(steps.get_pr_data.outputs.data).head.ref }}
git remote -v
git status
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v2

- name: Debug
run: |
ls -al
ls -al build
ls -al build/coverage
- name: Run sonar-scanner (PR mode)
if: github.event.workflow_run.event == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Put the name of your token here
run: |
sonar-scanner \
--define sonar.cfamily.compile-commands="build/compile_commands.json" \
--define sonar.coverageReportPaths=build/coverage/cov.xml \
--define sonar.projectVersion="${{ steps.next_version.outputs.content }}" \
--define sonar.scm.revision="${{ github.event.workflow_run.head_sha }}" \
--define sonar.pullrequest.key="${{ steps.pr_number.outputs.content }}" \
--define sonar.pullrequest.branch="${{ fromJson(steps.get_pr_data.outputs.data).head.ref }}" \
--define sonar.pullrequest.base="${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}"
- name: Run sonar-scanner (push mode)
if: github.event.workflow_run.event == 'push' && github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Put the name of your token here
run: |
sonar-scanner \
--define sonar.cfamily.compile-commands="build/compile_commands.json" \
--define sonar.coverageReportPaths=build/coverage/cov.xml \
--define sonar.projectVersion="${{ steps.next_version.outputs.content }}" \
--define sonar.branch.name=main
90 changes: 53 additions & 37 deletions CI/check_size_t.py → CI/check_type_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,56 @@
import re
import sys

ex = re.compile(r"(\b(?<!std::)size_t)\b")

type_list = [
"size_t",
"ptrdiff_t",
"nullptr_t",
"int8_t",
"int16_t",
"int32_t",
"int64_t",
"uint8_t",
"uint16_t",
"uint32_t",
"uint64_t",
"max_align_t",
]

github = "GITHUB_ACTIONS" in os.environ


def handle_file(file: Path, fix: bool, c_type: str) -> list[tuple[int, str]]:
ex = re.compile(rf"\b(?<!std::){c_type}\b")

content = file.read_text()
lines = content.splitlines()

changed_lines = []

for i, oline in enumerate(lines):
line, n_subs = ex.subn(rf"std::{c_type}", oline)
lines[i] = line
if n_subs > 0:
changed_lines.append((i, oline))

if fix and len(changed_lines) > 0:
file.write_text("\n".join(lines) + "\n")

return changed_lines


def main():
p = argparse.ArgumentParser()
p.add_argument("input")
p.add_argument(
"--fix", action="store_true", help="Attempt to fix any license issues found."
)
p.add_argument("--fix", action="store_true", help="Attempt to fix C-style types.")
p.add_argument("--exclude", "-e", action="append", default=[])

args = p.parse_args()

exit_code = 0

# walk over all files
exit = 0
for root, _, files in os.walk("."):
root = Path(root)
for filename in files:
Expand All @@ -44,38 +77,21 @@ def main():
if any([fnmatch(str(filepath), e) for e in args.exclude]):
continue

changed_lines = handle_file(filepath, fix=args.fix)
if len(changed_lines) > 0:
exit = 1
print()
print(filepath)
for i, oline in changed_lines:
print(f"{i}: {oline}")

if github:
print(
f"::error file={filepath},line={i+1},title=Do not use C-style size_t::Replace size_t with std::size_t"
)

return exit


def handle_file(file: Path, fix: bool) -> list[tuple[int, str]]:
content = file.read_text()
lines = content.splitlines()

changed_lines = []

for i, oline in enumerate(lines):
line, n_subs = ex.subn(r"std::size_t", oline)
lines[i] = line
if n_subs > 0:
changed_lines.append((i, oline))

if fix and len(changed_lines) > 0:
file.write_text("\n".join(lines) + "\n")

return changed_lines
for c_type in type_list:
changed_lines = handle_file(file=filepath, fix=args.fix, c_type=c_type)
if len(changed_lines) > 0:
exit_code = 1
print()
print(filepath)
for i, oline in changed_lines:
print(f"{i}: {oline}")

if github:
print(
f"::error file={filepath},line={i+1},title=Do not use C-style {c_type}::Replace {c_type} with std::{c_type}"
)

return exit_code


if "__main__" == __name__:
Expand Down
31 changes: 31 additions & 0 deletions CI/get_next_milestone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3

import os
import urllib.request
import json
import sys

GITHUB_TOKEN = os.environ["GH_TOKEN"]
GITHUB_REPO = os.environ["GH_REPO"]

with urllib.request.urlopen(
urllib.request.Request(
f"https://api.github.com/repos/{GITHUB_REPO}/milestones?state=open",
headers={"Authorization": f"Bearer {GITHUB_TOKEN}"},
)
) as response:
milestones = json.loads(response.read())


sys.stderr.write(f"Found {len(milestones)} milestones\n")
for m in milestones:
sys.stderr.write(f"- {m['title']}\n")


titles = [m["title"] for m in milestones if m["title"] != "next"]
titles.sort()

if len(titles) == 0:
raise RuntimeError("No eligible milestone found")

print(titles[0])
2 changes: 1 addition & 1 deletion CI/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def call(cmd):
+ ["-j", str(mp.cpu_count())]
+ excludes
+ extra_flags
+ ["--xml", "-o", "coverage/cov.xml"]
+ ["--sonarqube", "coverage/cov.xml"]
)

call(
Expand Down
Loading

0 comments on commit e0d23c0

Please sign in to comment.