Skip to content

Commit

Permalink
Merge pull request #213 from WeiqunZhang/ccache
Browse files Browse the repository at this point in the history
Update CI
  • Loading branch information
asalmgren authored Jun 19, 2024
2 parents 9481bea + 9e93bf8 commit f66ff4e
Show file tree
Hide file tree
Showing 13 changed files with 347 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/c-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
cpp-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

Expand All @@ -30,7 +30,7 @@ jobs:
run: python3 Submodules/cpp-linter-action/run_on_changed_files.py ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -header-filter=Source/ -ignore-files="AMReX|GoogleTest" -run-linter

- name: Archive clang tidy report
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: clang-tidy-report
path: clang-tidy-report.txt
41 changes: 38 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

steps:

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

Expand All @@ -39,12 +39,24 @@ jobs:
# Install MPI
${{matrix.install_deps}}
- name: Install CCache
run: Submodules/AMReX/.github/workflows/dependencies/dependencies_ccache.sh

- name: Set Up Cache
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-${{ github.workflow }}-${{ github.job }}-git-${{ github.sha }}
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-git-
- name: Configure CMake
run: |
cmake \
-B${{runner.workspace}}/REMORA/build-${{matrix.os}} \
-DCMAKE_INSTALL_PREFIX:PATH=${{runner.workspace}}/REMORA/install \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DREMORA_DIM:STRING=3 \
-DREMORA_ENABLE_MPI:BOOL=ON \
-DREMORA_ENABLE_TESTS:BOOL=ON \
Expand All @@ -56,8 +68,16 @@ jobs:
- name: Build
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
export CCACHE_MAXSIZE=600M
ccache -z
cmake --build ${{runner.workspace}}/REMORA/build-${{matrix.os}} --parallel ${{env.NPROCS}};
ccache -s
du -hs ~/.cache/ccache
- name: Regression Tests
run: |
ctest -L regression -VV
Expand All @@ -74,16 +94,31 @@ jobs:
# cd ..
# gcovr -g -k -r . --xml regressioncov.html # -v
# - name: Success artifacts
# uses: actions/upload-artifact@v3
# uses: actions/upload-artifact@v4
# if: success()
# with:
# name: build-and-test
# path: |
# ${{runner.workspace}}/REMORA/regressioncov.html
# - name: Failing test artifacts
# uses: actions/upload-artifact@v3
# uses: actions/upload-artifact@v4
# if: failure()
# with:
# name: build-and-test
# path: |
# ${{runner.workspace}}/REMORA/regressioncov.html

save_pr_number:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
retention-days: 1
40 changes: 40 additions & 0 deletions .github/workflows/cleanup-cache-postpr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CleanUpCachePostPR

on:
workflow_run:
workflows: [PostPR]
types:
- completed

jobs:
CleanUpCcacheCachePostPR:
name: Clean Up Ccache Cache Post PR
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Clean up ccache
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
gh run download ${{ github.event.workflow_run.id }} -n pr_number
pr_number=`cat pr_number.txt`
BRANCH=refs/pull/${pr_number}/merge
# Setting this to not fail the workflow while deleting cache keys.
set +e
keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH | cut -f 1)
# $keys might contain spaces. Thus we set IFS to \n.
IFS=$'\n'
for k in $keys
do
gh actions-cache delete "$k" -R $REPO -B $BRANCH --confirm
done
unset IFS
63 changes: 63 additions & 0 deletions .github/workflows/cleanup-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CleanUpCache

on:
workflow_run:
workflows: [REMORA CI, REMORA CUDA CI, REMORA CI (hip), REMORA CI (sycl), Linux GCC, MacOS]
types:
- completed

jobs:
CleanUpCcacheCache:
name: Clean Up Ccache Cache for ${{ github.event.workflow_run.name }}
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Clean up ccache
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
# push or pull_request or schedule or ...
EVENT=${{ github.event.workflow_run.event }}
# Triggering workflow run name (e.g., LinuxClang)
WORKFLOW_NAME="${{ github.event.workflow_run.name }}"
if [[ $EVENT == "pull_request" ]]; then
gh run download ${{ github.event.workflow_run.id }} -n pr_number
pr_number=`cat pr_number.txt`
BRANCH=refs/pull/${pr_number}/merge
else
BRANCH=refs/heads/${{ github.event.workflow_run.head_branch }}
fi
# Setting this to not fail the workflow while deleting cache keys.
set +e
# In our cache keys, substring after `-git-` is git hash, substring
# before that is a unique id for jobs (e.g., `ccache-LinuxClang-configure-2d`).
# The goal is to keep the last used key of each job and delete all others.
# something like ccache-LinuxClang-
keyprefix="ccache-${WORKFLOW_NAME}-"
cached_jobs=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH --key "$keyprefix" | awk -F '-git-' '{print $1}' | sort | uniq)
# cached_jobs is something like "ccache-LinuxClang-configure-1d ccache-LinuxClang-configure-2d".
# It might also contain spaces. Thus we set IFS to \n.
IFS=$'\n'
for j in $cached_jobs
do
old_keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH --key "${j}-git-" --sort last-used | cut -f 1 | tail -n +2)
for k in $old_keys
do
gh actions-cache delete "$k" -R $REPO -B $BRANCH --confirm
done
done
unset IFS
36 changes: 35 additions & 1 deletion .github/workflows/cuda-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,55 @@ jobs:
uses: styfle/[email protected]
with:
access_token: ${{github.token}}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: Prepare CUDA environment
run: Submodules/AMReX/.github/workflows/dependencies/dependencies_nvcc.sh ${{matrix.cuda_ver}}
- name: Install CCache
run: Submodules/AMReX/.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-${{ github.workflow }}-${{ github.job }}-git-${{ github.sha }}
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-git-
- name: Configure and build
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
export CCACHE_MAXSIZE=600M
ccache -z
export PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
which nvcc || echo "nvcc not in PATH!"
cmake -Bbuild-${{matrix.cuda_pkg}} \
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
-DAMReX_CUDA_ERROR_CROSS_EXECUTION_SPACE_CALL=ON \
-DAMReX_CUDA_ERROR_CAPTURE_THIS=ON \
-DREMORA_DIM:STRING=3 \
-DREMORA_ENABLE_MPI:BOOL=OFF \
-DREMORA_ENABLE_CUDA:BOOL=ON .
cmake --build build-${{matrix.cuda_pkg}} -- -j $(nproc)
ccache -s
du -hs ~/.cache/ccache
save_pr_number:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
retention-days: 1
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Dependencies
run: |
Expand Down
37 changes: 36 additions & 1 deletion .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,46 @@ jobs:
runs-on: ubuntu-20.04
# env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual"}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

- name: Install Dependencies
run: Submodules/AMReX/.github/workflows/dependencies/dependencies.sh

- name: Install CCache
run: Submodules/AMReX/.github/workflows/dependencies/dependencies_ccache.sh

- name: Set Up Cache
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-${{ github.workflow }}-${{ github.job }}-git-${{ github.sha }}
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-git-
- name: Configure Project and Generate Build System
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
export CCACHE_MAXSIZE=300M
ccache -z
cmake \
-B${{runner.workspace}}/REMORA/build \
-DCMAKE_INSTALL_PREFIX:PATH=${{runner.workspace}}/REMORA/install \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DREMORA_DIM:STRING=3 \
-DREMORA_ENABLE_MPI:BOOL=ON \
-DREMORA_ENABLE_TESTS:BOOL=ON \
-DREMORA_ENABLE_ALL_WARNINGS:BOOL=ON \
-DREMORA_ENABLE_FCOMPARE:BOOL=ON \
${{github.workspace}};
ccache -s
du -hs ~/.cache/ccache
- name: Compile and Link
run: |
cmake --build ${{runner.workspace}}/REMORA/build --parallel 2 --verbose
Expand All @@ -40,3 +60,18 @@ jobs:
run: |
ctest -L regression -VV
working-directory: ${{runner.workspace}}/REMORA/build

save_pr_number:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
retention-days: 1
Loading

0 comments on commit f66ff4e

Please sign in to comment.