Skip to content

Commit 413230e

Browse files
authored
Merge pull request #33 from mc-rtc/optional-ccache
Optional ccache overlay
2 parents 267f86e + 48c0953 commit 413230e

16 files changed

Lines changed: 514 additions & 1058 deletions

.github/workflows/nix-private.yml renamed to .github/workflows/nix-variants-private.yml

Lines changed: 18 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# build variants.private and variants.private-ccache
2+
# push cache to mc-rtc-nix-private attic
3+
# TODO we cannot use nix flake check to ensure that everything is built
4+
# so currently we build the largest meta-packages available (mc-rtc-superbuild-private, mc-mujoco-full, etc)
15
name: "CI - Nix - Private"
26
on:
37
push:
@@ -13,14 +17,14 @@ jobs:
1317
# - The PR's source repo is the same as the base repo.
1418
# This is done to make sure that the required secrets are available to the CI
1519
if: github.event_name != 'pull_request' || github.repository == github.event.pull_request.head.repo.full_name
16-
name: "${{ matrix.build }} on ${{ matrix.os }}"
20+
name: "${{matrix.variant}}: ${{ matrix.build }} on ${{ matrix.os }}"
1721
runs-on: "${{ matrix.os }}"
1822
strategy:
1923
fail-fast: false
2024
matrix:
2125
os: [ubuntu-24.04]
22-
# test with mc-hrp2 for now
23-
build: [ "mc-hrp2", "mc-rtc-superbuild-private" ]
26+
variant: [ "private", "private-ccache" ]
27+
build: [ "mc-mujoco-full", "mc-rtc-superbuild-private" ]
2428
steps:
2529
- uses: actions/checkout@v6
2630
# Configures ssh-agent if SSH_KEY secret exists
@@ -44,37 +48,18 @@ jobs:
4448
endpoint: https://attic.arntanguy.fr
4549
cache: mc-rtc-nix-private
4650
token: ${{ secrets.ATTIC_TOKEN }}
47-
- run: nix build -L "./private#${{ matrix.build }}" --cores 4
48-
complete:
49-
if: github.event_name != 'pull_request' || github.repository == github.event.pull_request.head.repo.full_name
50-
needs: populate-cache
51-
name: "complete ${{ matrix.os }}"
52-
runs-on: "${{ matrix.os }}-latest"
53-
strategy:
54-
fail-fast: false
55-
matrix:
56-
os: [ubuntu] # TODO: macos
57-
steps:
58-
- uses: jlumbroso/free-disk-space@main
59-
if: ${{ matrix.os == 'ubuntu' }}
60-
- name: Configure ssh-agent
61-
uses: webfactory/ssh-agent@v0.9.0
62-
with:
63-
ssh-private-key: ${{ secrets.SSH_KEY }}
64-
- name: Add gite.lirmm.fr to known_hosts
51+
- name: Setup ccache environment
6552
run: |
66-
ssh-keyscan gite.lirmm.fr >> ~/.ssh/known_hosts
67-
- uses: actions/checkout@v6
68-
- uses: cachix/install-nix-action@v31
69-
- uses: cachix/cachix-action@v17
70-
with:
71-
name: mc-rtc-nix
72-
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
73-
extraPullNames: "ros,gepetto"
74-
- run: nix flake check -L ./private
53+
sudo mkdir -m0770 -p '/var/cache/ccache'
54+
sudo chown --reference=/nix/store '/var/cache/ccache'
55+
mkdir -p ~/.config/nix
56+
echo 'extra-sandbox-paths = /var/cache/ccache' | sudo tee -a /etc/nix/nix.conf
57+
sudo systemctl restart nix-daemon.service
58+
sudo ls -ld /var/cache/ccache
59+
- run: nix build -L ".#variants.${{ matrix.variant }}.packages.x86_64-linux.${{ matrix.build }}" --cores 4
7560
fallback:
76-
needs: complete
77-
if: always() && needs.complete.result == 'failure'
61+
needs: populate-cache
62+
if: always() && needs.populate-cache.result == 'failure'
7863
name: "fallback ${{ matrix.os }}"
7964
runs-on: "${{ matrix.os }}-latest"
8065
strategy:
@@ -98,36 +83,13 @@ jobs:
9883
name: mc-rtc-nix
9984
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
10085
extraPullNames: "ros,gepetto"
101-
- run: nix flake check -L -j 1 --cores 1
102-
# system:
103-
# runs-on: "ubuntu-latest"
104-
# steps:
105-
# - uses: actions/checkout@v6
106-
# - uses: cachix/install-nix-action@v31
107-
# - uses: cachix/cachix-action@v17
108-
# with:
109-
# name: mc-rtc-nix
110-
# authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
111-
# extraPullNames: ros
112-
# - run: nix build -L .#systemConfigs.default
113-
# home:
114-
# runs-on: "ubuntu-latest"
115-
# steps:
116-
# - uses: actions/checkout@v6
117-
# - uses: cachix/install-nix-action@v31
118-
# - uses: cachix/cachix-action@v17
119-
# with:
120-
# name: mc-rtc-nix
121-
# extraPullNames: "ros,gepetto"
122-
# - run: nix build -L .#homeConfigurations.cpene.activationPackage
86+
- run: nix build -L ".#variants.${{ matrix.variant }}.packages.x86_64-linux.${{ matrix.build }}" --cores 1
12387
check:
12488
if: always()
12589
name: check-macos-linux-nix-private
12690
runs-on: ubuntu-latest
12791
needs:
12892
- fallback
129-
# - system
130-
# - home
13193
steps:
13294
- uses: re-actors/alls-green@release/v1
13395
with:
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# build variants.ccache
2+
# push cache to cachix
3+
# TODO we cannot use nix flake check to ensure that everything is built
4+
# so currently we build the largest meta-packages available (mc-rtc-superbuild-private, mc-mujoco-full, etc)
5+
name: "CI - Nix - ccache"
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
branches:
12+
- main
13+
jobs:
14+
populate-cache:
15+
# - This condition allows the job to run if:
16+
# - The workflow is not triggered by a pull request (`github.event_name != 'pull_request'`), or
17+
# - The PR's source repo is the same as the base repo.
18+
# This is done to make sure that the required secrets are available to the CI
19+
if: github.event_name != 'pull_request' || github.repository == github.event.pull_request.head.repo.full_name
20+
name: "${{matrix.variant}}: ${{ matrix.build }} on ${{ matrix.os }}"
21+
runs-on: "${{ matrix.os }}"
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
os: [ubuntu-24.04]
26+
variant: [ "ccache" ]
27+
build: [ "mc-mujoco-full", "mc-rtc-superbuild-full" ]
28+
steps:
29+
- uses: actions/checkout@v6
30+
- uses: cachix/install-nix-action@v31
31+
- &cachix-step
32+
uses: cachix/cachix-action@v17
33+
with:
34+
name: mc-rtc-nix
35+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
36+
extraPullNames: "ros,gepetto"
37+
- &setup-ccache
38+
name: Setup ccache environment
39+
run: |
40+
sudo mkdir -m0770 -p '/var/cache/ccache'
41+
sudo chown --reference=/nix/store '/var/cache/ccache'
42+
mkdir -p ~/.config/nix
43+
echo 'extra-sandbox-paths = /var/cache/ccache' | sudo tee -a /etc/nix/nix.conf
44+
sudo systemctl restart nix-daemon.service
45+
sudo ls -ld /var/cache/ccache
46+
- run: nix build -L ".#variants.${{ matrix.variant }}.packages.x86_64-linux.${{ matrix.build }}" --cores 4
47+
fallback:
48+
needs: populate-cache
49+
if: always() && needs.populate-cache.result == 'failure'
50+
name: "fallback ${{ matrix.os }}"
51+
runs-on: "${{ matrix.os }}-latest"
52+
strategy:
53+
fail-fast: false
54+
matrix:
55+
os: [ubuntu] # TODO: macos
56+
steps:
57+
- uses: jlumbroso/free-disk-space@main
58+
if: ${{ matrix.os == 'ubuntu' }}
59+
- uses: actions/checkout@v6
60+
- uses: cachix/install-nix-action@v31
61+
- <<: *cachix-step
62+
- <<: *setup-ccache
63+
- run: nix build -L ".#variants.${{ matrix.variant }}.packages.x86_64-linux.${{ matrix.build }}" --cores 1
64+
check:
65+
if: always()
66+
name: check-macos-linux-nix-private
67+
runs-on: ubuntu-latest
68+
needs:
69+
- fallback
70+
steps:
71+
- uses: re-actors/alls-green@release/v1
72+
with:
73+
allowed-skips: fallback
74+
jobs: ${{ toJSON(needs) }}
75+

0 commit comments

Comments
 (0)