Skip to content

Commit

Permalink
CI: Use sccache action from marketplace
Browse files Browse the repository at this point in the history
  • Loading branch information
mwestphal committed Aug 30, 2024
1 parent 7953f51 commit df8753b
Showing 1 changed file with 35 additions and 184 deletions.
219 changes: 35 additions & 184 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
env:
CCACHE_DIR: /home/runner/.ccache
CCACHE_MAXSIZE: 500M

steps:
- uses: actions/checkout@v3
Expand All @@ -53,7 +50,7 @@ jobs:
sudo apt update
# TTK dependencies
sudo apt install -y \
ccache \
sccache \
libboost-system-dev \
libeigen3-dev \
libgraphviz-dev \
Expand All @@ -68,6 +65,11 @@ jobs:
dpkg-dev
sudo python3 -m pip install scikit-learn
- name: Install and setup sccache
uses: f3d-app/sccache-setup-action@v1
with:
key: ${{ matrix.os }}-0

- name: Install optional dependencies
uses: ./.github/actions/install-deps-unix

Expand All @@ -79,18 +81,6 @@ jobs:
unzip libtorch-cxx11-abi-shared-with-deps-2.3.1+cpu.zip
sudo cp -R libtorch/* /usr/local/
- name: Fetch archived ccache
continue-on-error: true
run: |
wget -O ttk-ccache.tar.gz \
https://github.com/topology-tool-kit/ttk/releases/download/ccache/ttk-ccache-${{ matrix.os }}.tar.gz
- name: Decompress ccache archive
continue-on-error: true
run: |
tar xzf ttk-ccache.tar.gz
mv .ccache /home/runner/
- name: Fetch TTK-ParaView headless Debian package
run: |
wget -O ttk-paraview-headless.deb \
Expand All @@ -106,8 +96,8 @@ jobs:
cd build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DCMAKE_INSTALL_PREFIX=/usr \
-DTTK_BUILD_PARAVIEW_PLUGINS=TRUE \
-DTTK_BUILD_VTK_WRAPPERS=TRUE \
Expand All @@ -130,6 +120,10 @@ jobs:
cpack -G DEB
sudo cmake --build . --target install
- name: Show sccache results
shell: bash
run: sccache --show-stats

- name: Run TTK tests
uses: ./.github/actions/test-ttk-unix

Expand All @@ -139,21 +133,6 @@ jobs:
name: ttk-for-tests-${{ matrix.os }}.deb
path: build/ttk.deb

- name: Archive cache
run: |
ccache -s
ccache -c
cd /home/runner
tar czf ttk-ccache.tar.gz .ccache
- name: Upload ccache archive
if: ${{ github.repository_owner == 'topology-tool-kit' && contains(github.ref, 'heads') }}
uses: actions/upload-artifact@v3
with:
name: ttk-ccache-${{ matrix.os }}
path: /home/runner/ttk-ccache.tar.gz
retention-days: 2


# ------------------#
# Tests on ttk-data #
Expand Down Expand Up @@ -279,9 +258,7 @@ jobs:
test-build-macos:
runs-on: macos-12
if: ${{ github.repository_owner == 'topology-tool-kit' || !contains(github.ref, 'heads') }}
env:
CCACHE_DIR: /Users/runner/work/ttk/.ccache
CCACHE_MAXSIZE: 200M

steps:
- uses: actions/checkout@v3
name: Checkout TTK source code
Expand All @@ -297,25 +274,16 @@ jobs:
brew install --cask xquartz
brew install wget llvm libomp ninja open-mpi
# TTK dependencies
brew install boost eigen graphviz numpy qhull ccache
# prepend ccache to system path
echo "$(brew --prefix)/opt/ccache/libexec" >> $GITHUB_PATH
brew install boost eigen graphviz numpy qhull
- name: Install and setup sccache
uses: f3d-app/sccache-setup-action@v1
with:
key: macos-0

- name: Install optional dependencies
uses: ./.github/actions/install-deps-unix

- name: Fetch archived ccache
continue-on-error: true
run: |
wget https://github.com/topology-tool-kit/ttk/releases/download/ccache/ttk-ccache-macOS.tar.gz
- name: Decompress ccache archive
continue-on-error: true
run: |
tar xzf ttk-ccache-macOS.tar.gz
rm -rf /Users/runner/work/ttk/.ccache
mv .ccache /Users/runner/work/ttk/
- name: Fetch TTK-ParaView headless macOS binary archive
run: |
wget https://github.com/${{ env.PV_REPO }}/releases/download/${{ env.PV_TAG }}/ttk-paraview-headless.tar.gz
Expand All @@ -337,8 +305,8 @@ jobs:
cd build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DTTK_BUILD_PARAVIEW_PLUGINS=TRUE \
-DTTK_BUILD_VTK_WRAPPERS=TRUE \
-DTTK_BUILD_STANDALONE_APPS=TRUE \
Expand All @@ -359,6 +327,10 @@ jobs:
cmake --build . --parallel
sudo cmake --build . --target install
- name: Show sccache results
shell: bash
run: sccache --show-stats

- name: Set PYTHONPATH for macOS pvpython
run: |
# pvpython does not embed the correct PYTHONPATH
Expand Down Expand Up @@ -407,22 +379,6 @@ jobs:
cat python/res.json
diff python/hashes/macOS.json python/res.json
- name: Archive cache
run: |
ccache -s
ccache -c
cd /Users/runner/work/ttk
tar czf ttk-ccache.tar.gz .ccache
- name: Upload ccache archive
if: ${{ github.repository_owner == 'topology-tool-kit' && contains(github.ref, 'heads') }}
uses: actions/upload-artifact@v3
with:
name: ttk-ccache-macOS
path: /Users/runner/work/ttk/ttk-ccache.tar.gz
retention-days: 2


# ------------------ #
# Test Windows build #
# ------------------ #
Expand All @@ -433,7 +389,6 @@ jobs:
PV_DIR: C:\Program Files\TTK-ParaView
TTK_DIR: C:\Program Files (x86)\ttk
CONDA_ROOT: C:\Miniconda
SCCACHE_CACHE_SIZE: 200M
steps:
- uses: actions/checkout@v3
name: Checkout TTK source code
Expand All @@ -444,32 +399,22 @@ jobs:
shell: bash
run: |
conda install -c conda-forge libboost-devel glew eigen spectralib zfp \
scikit-learn graphviz ninja sccache=0.4.2 python=3.10 zlib qhull llvm-openmp clangxx
# add sccache to PATH
echo "$CONDA_ROOT/bin" >> $GITHUB_PATH
scikit-learn graphviz ninja python=3.10 zlib qhull llvm-openmp clangxx
# add TTK & ParaView install folders to PATH
echo "$PV_DIR/bin" >> $GITHUB_PATH
echo "$TTK_DIR/bin" >> $GITHUB_PATH
conda info --all
- name: Install and setup sccache
uses: f3d-app/sccache-setup-action@v1
with:
key: windows-0

- name: Remove hosted Python
shell: bash
run: |
rm -rf C:/hostedtoolcache/windows/Python
- name: Fetch archived ccache
continue-on-error: true
run: |
curl.exe -OL https://github.com/topology-tool-kit/ttk/releases/download/ccache/ttk-sccache-windows.tar.gz
- name: Decompress ccache archive
continue-on-error: true
shell: bash
run: |
tar xzf ttk-sccache-windows.tar.gz
mkdir -p /c/Users/runneradmin/AppData/Local/Mozilla/sccache
mv cache /c/Users/runneradmin/AppData/Local/Mozilla/sccache
- name: Fetch TTK-ParaView headless Windows installer
run: |
curl.exe -OL https://github.com/${{ env.PV_REPO }}/releases/download/${{ env.PV_TAG }}/ttk-paraview-headless.exe
Expand All @@ -486,8 +431,6 @@ jobs:
set CC=clang-cl.exe
set CXX=clang-cl.exe
call "%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
sccache --stop-server
sccache --start-server
mkdir build
cd build
cmake ^
Expand Down Expand Up @@ -530,6 +473,10 @@ jobs:
call "%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cmake --build . --config Release --parallel --target install
- name: Show sccache results
shell: bash
run: sccache --show-stats

- name: Test C++ example
shell: cmd
run: |
Expand Down Expand Up @@ -610,99 +557,3 @@ jobs:
cd ttk-data
type python\res.json
FC python\hashes\windows.json python\res.json
- name: Archive cache
shell: bash
run: |
sccache -s
cd /c/Users/runneradmin/AppData/Local/Mozilla/sccache
tar czf ttk-sccache.tar.gz cache
- name: Upload sccache archive
if: ${{ github.repository_owner == 'topology-tool-kit' && contains(github.ref, 'heads') }}
uses: actions/upload-artifact@v3
with:
name: ttk-sccache-windows
path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache\ttk-sccache.tar.gz
retention-days: 2


# ---------------------------------------- #
# Upload ccache archives as release assets #
# ---------------------------------------- #
ccache-release:
runs-on: ubuntu-latest
needs: [test-build-ubuntu, test-build-macos, test-build-windows]
# trigger job only on the "topology-tool-kit" repository in case
# of a branch push (pull requests and tags not affected)
if: ${{ github.repository_owner == 'topology-tool-kit' && contains(github.ref, 'heads') }}
steps:

- name: Delete previous release
uses: actions/github-script@v6
continue-on-error: true
with:
script: |
const { owner, repo } = context.repo
const { data: { id } } = await github.rest.repos.getReleaseByTag({
owner,
repo,
tag: "ccache"
})
await github.rest.repos.deleteRelease({ owner, repo, release_id: id })
- name: Create Release
uses: actions/github-script@v6
with:
script: |
const { owner, repo } = context.repo
await github.rest.repos.createRelease({
owner,
repo,
tag_name: "ccache",
name: "ccache archives",
body: "Holds ccache archives to speed up build jobs",
draft: false,
prerelease: true
})
- name: Fetch all uploaded artifacts
uses: actions/download-artifact@v3

- name: Upload Ubuntu Focal .deb as Release Asset
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ccache
file: ttk-ccache-ubuntu-20.04/ttk-ccache.tar.gz
asset_name: ttk-ccache-ubuntu-20.04.tar.gz

- name: Upload Ubuntu Jammy .deb as Release Asset
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ccache
file: ttk-ccache-ubuntu-22.04/ttk-ccache.tar.gz
asset_name: ttk-ccache-ubuntu-22.04.tar.gz

- name: Upload .pkg as Release Asset
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ccache
file: ttk-ccache-macOS/ttk-ccache.tar.gz
asset_name: ttk-ccache-macOS.tar.gz

- name: Upload sccache Windows archive
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ccache
file: ttk-sccache-windows/ttk-sccache.tar.gz
asset_name: ttk-sccache-windows.tar.gz

- name: Delete ccache artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: |
ttk-*ccache*

0 comments on commit df8753b

Please sign in to comment.