diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index cc170113f..41936aa0b 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -4,8 +4,21 @@ on: branches: [ main ] pull_request: jobs: + id_repo: + runs-on: ubuntu-latest + outputs: + in_base_repo: ${{ steps.identify_repo.outputs.in_base_repo }} + steps: + - name: Identify repository + id: identify_repo + run: | + echo "in_base_repo=${{ (github.event == 'push' && github.repository == 'Maison-de-la-Simulation/ddc') || github.event.pull_request.head.repo.full_name == 'Maison-de-la-Simulation/ddc' }}" >> "$GITHUB_OUTPUT" + echo "$GITHUB_OUTPUT" docker-build: + needs: id_repo runs-on: ubuntu-latest + outputs: + doxygen_image: ${{ steps.image_output.outputs.doxygen_image }} steps: - name: Checkout built branch uses: actions/checkout@v3 @@ -17,21 +30,51 @@ jobs: --cache-from ghcr.io/maison-de-la-simulation/ddc/doxygen \ -t ghcr.io/maison-de-la-simulation/ddc/doxygen \ -t ghcr.io/maison-de-la-simulation/ddc/doxygen:${GITHUB_SHA:0:7} \ + -t doxygen_image \ docker/doxygen + - name: Publish doxygen artifact for current SHA + if: ${{ needs.id_repo.outputs.in_base_repo == 'true' }} + run: | + echo "doxygen_image=ghcr.io/maison-de-la-simulation/ddc/doxygen:${GITHUB_SHA:0:7}" >> $GITHUB_ENV docker push ghcr.io/maison-de-la-simulation/ddc/doxygen:${GITHUB_SHA:0:7} + - name: Create doxygen docker artifact + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + run: | + echo "doxygen_image=doxygen_image" >> $GITHUB_ENV + docker save doxygen_image > doxygen.tar - name: Publish - if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} + if: ${{ github.event_name == 'push' && github.ref_name == 'main' && needs.id_repo.outputs.in_base_repo == 'true' }} run: | docker push ghcr.io/maison-de-la-simulation/ddc/doxygen + - name: Save doxygen docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + uses: actions/upload-artifact@v3 + with: + name: doxygen-artifact + path: doxygen.tar + retention-days: 1 + - name: Output image + id: image_output + run: | + echo "doxygen_image=${doxygen_image}" >> "$GITHUB_OUTPUT" pages: runs-on: ubuntu-latest - needs: docker-build + needs: [docker-build, id_repo] steps: - name: Checkout built branch uses: actions/checkout@v3 with: fetch-depth: 0 submodules: true + - name: Collect doxygen docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + uses: actions/download-artifact@v3 + with: + name: doxygen-artifact + - name: Load doxygen docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + run: | + docker load < doxygen.tar - name: Build site run: | cat<<-EOF > run.sh @@ -43,9 +86,9 @@ jobs: EOF mkdir docs_out chmod a+rwx docs_out - docker run -v ${PWD}:/src ghcr.io/maison-de-la-simulation/ddc/doxygen:${GITHUB_SHA:0:7} bash /src/run.sh + docker run -v ${PWD}:/src ${{ needs.docker-build.outputs.doxygen_image }} bash /src/run.sh - name: Publish site - if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} + if: ${{ github.event_name == 'push' && github.ref_name == 'main' && needs.id_repo.outputs.in_base_repo == 'true' }} run: | git worktree add -B gh-pages public remotes/origin/gh-pages find public -mindepth 1 -maxdepth 1 '!' -name .git -exec rm -rf '{}' '+' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 79033ce8d..efbd62078 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,8 +4,22 @@ on: branches: [ main ] pull_request: jobs: + id_repo: + runs-on: ubuntu-latest + outputs: + in_base_repo: ${{ steps.identify_repo.outputs.in_base_repo }} + steps: + - name: Identify repository + id: identify_repo + run: | + echo "in_base_repo=${{ (github.event == 'push' && github.repository == 'Maison-de-la-Simulation/ddc') || github.event.pull_request.head.repo.full_name == 'Maison-de-la-Simulation/ddc' }}" >> "$GITHUB_OUTPUT" + echo "$GITHUB_OUTPUT" + docker-build-test_env: + needs: id_repo runs-on: ubuntu-latest + outputs: + test_env_image: ${{ steps.image_output.outputs.test_env_image }} steps: - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main @@ -17,7 +31,7 @@ jobs: android: true dotnet: true haskell: true - large-packages: false + large-packages: true swap-storage: true - name: Checkout built branch uses: actions/checkout@v3 @@ -29,14 +43,39 @@ jobs: --cache-from ghcr.io/maison-de-la-simulation/ddc/test_env \ -t ghcr.io/maison-de-la-simulation/ddc/test_env \ -t ghcr.io/maison-de-la-simulation/ddc/test_env:${GITHUB_SHA:0:7} \ + -t test_env_image \ docker/test_env + - name: Publish test_env artifact for current SHA + if: ${{ needs.id_repo.outputs.in_base_repo == 'true' }} + run: | + echo "test_env_image=ghcr.io/maison-de-la-simulation/ddc/test_env:${GITHUB_SHA:0:7}" >> $GITHUB_ENV docker push ghcr.io/maison-de-la-simulation/ddc/test_env:${GITHUB_SHA:0:7} + - name: Create test_env docker artifact + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + run: | + echo "test_env_image=test_env_image" >> $GITHUB_ENV + docker save test_env_image > test_env.tar - name: Publish - if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} + if: ${{ github.event_name == 'push' && github.ref_name == 'main' && needs.id_repo.outputs.in_base_repo == 'true' }} run: | docker push ghcr.io/maison-de-la-simulation/ddc/test_env + - name: Save test_env docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + uses: actions/upload-artifact@v3 + with: + name: test_env-artifact + path: test_env.tar + retention-days: 1 + - name: Output image + id: image_output + run: | + echo "test_env_image=${test_env_image}" >> "$GITHUB_OUTPUT" + docker-build-jammy_env: + needs: id_repo runs-on: ubuntu-latest + outputs: + jammy_image: ${{ steps.image_output.outputs.jammy_image }} steps: - name: Checkout built branch uses: actions/checkout@v3 @@ -48,12 +87,34 @@ jobs: --cache-from ghcr.io/maison-de-la-simulation/ddc/jammy_env \ -t ghcr.io/maison-de-la-simulation/ddc/jammy_env \ -t ghcr.io/maison-de-la-simulation/ddc/jammy_env:${GITHUB_SHA:0:7} \ + -t jammy_env_image \ docker/jammy_env + - name: Publish jammy_env artifact for current SHA + if: ${{ needs.id_repo.outputs.in_base_repo == 'true' }} + run: | + echo "jammy_image=ghcr.io/maison-de-la-simulation/ddc/jammy_env:${GITHUB_SHA:0:7}" >> $GITHUB_ENV docker push ghcr.io/maison-de-la-simulation/ddc/jammy_env:${GITHUB_SHA:0:7} + - name: Create jammy_env artifact + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + run: | + echo "jammy_image=jammy_env_image" >> $GITHUB_ENV + docker save jammy_env_image > jammy_env.tar - name: Publish - if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} + if: ${{ github.event_name == 'push' && github.ref_name == 'main' && needs.id_repo.outputs.in_base_repo == 'true' }} run: | docker push ghcr.io/maison-de-la-simulation/ddc/jammy_env + - name: Save jammy_env docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + uses: actions/upload-artifact@v3 + with: + name: jammy_env-artifact + path: jammy_env.tar + retention-days: 1 + - name: Output image + id: image_output + run: | + echo "jammy_image=${jammy_image}" >> "$GITHUB_OUTPUT" + lint: runs-on: ubuntu-latest steps: @@ -64,14 +125,36 @@ jobs: exclude: '' extensions: 'hpp,cpp' clangFormatVersion: 12 + test-Debug: runs-on: ubuntu-latest - needs: docker-build-test_env + needs: [docker-build-test_env, id_repo] steps: - name: Checkout built branch uses: actions/checkout@v3 with: submodules: recursive + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + swap-storage: true + - name: Collect test_env docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + uses: actions/download-artifact@v3 + with: + name: test_env-artifact + - name: Load test_env docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + run: | + docker load < test_env.tar - name: Build run: | cat<<-EOF > run.sh @@ -81,15 +164,37 @@ jobs: make -j 2 VERBOSE=1 ctest -j 2 --output-on-failure --timeout 5 --output-junit tests.xml EOF - docker run -v ${PWD}:/src:ro ghcr.io/maison-de-la-simulation/ddc/test_env:${GITHUB_SHA:0:7} bash /src/run.sh + docker run -v ${PWD}:/src:ro ${{ needs.docker-build-test_env.outputs.test_env_image }} bash /src/run.sh + test-Release: runs-on: ubuntu-latest - needs: docker-build-test_env + needs: [docker-build-test_env, id_repo] steps: - name: Checkout built branch uses: actions/checkout@v3 with: submodules: recursive + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + swap-storage: true + - name: Collect test_env docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + uses: actions/download-artifact@v3 + with: + name: test_env-artifact + - name: Load test_env docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + run: | + docker load < test_env.tar - name: Build run: | cat<<-EOF > run.sh @@ -99,15 +204,37 @@ jobs: make -j 2 VERBOSE=1 ctest -j 2 --output-on-failure --timeout 5 --output-junit tests.xml EOF - docker run -v ${PWD}:/src:ro ghcr.io/maison-de-la-simulation/ddc/test_env:${GITHUB_SHA:0:7} bash /src/run.sh + docker run -v ${PWD}:/src:ro ${{ needs.docker-build-test_env.outputs.test_env_image }} bash /src/run.sh + test-cuda: runs-on: ubuntu-latest - needs: docker-build-jammy_env + needs: [docker-build-jammy_env, id_repo] steps: - name: Checkout built branch uses: actions/checkout@v3 with: submodules: recursive + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + swap-storage: true + - name: Collect jammy_env docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + uses: actions/download-artifact@v3 + with: + name: jammy_env-artifact + - name: Load jammy_env docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + run: | + docker load < jammy_env.tar - name: Build run: | cat<<-EOF > run.sh @@ -119,15 +246,37 @@ jobs: cmake -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror=vla" -DBUILD_BENCHMARKS=ON -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON -DKokkos_ENABLE_LIBDL=OFF -DKokkos_ENABLE_DEPRECATED_CODE_3=OFF -DKokkos_ENABLE_DEPRECATED_CODE_4=OFF -DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF /src make -j 2 VERBOSE=1 EOF - docker run -v ${PWD}:/src:ro ghcr.io/maison-de-la-simulation/ddc/jammy_env:${GITHUB_SHA:0:7} bash /src/run.sh + docker run -v ${PWD}:/src:ro ${{ needs.docker-build-jammy_env.outputs.jammy_image }} bash /src/run.sh + test-hip: runs-on: ubuntu-latest - needs: docker-build-test_env + needs: [docker-build-test_env, id_repo] steps: - name: Checkout built branch uses: actions/checkout@v3 with: submodules: recursive + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + swap-storage: true + - name: Collect test_env docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + uses: actions/download-artifact@v3 + with: + name: test_env-artifact + - name: Load test_env docker + if: ${{ needs.id_repo.outputs.in_base_repo == 'false' }} + run: | + docker load < test_env.tar - name: Build run: | cat<<-EOF > run.sh @@ -138,4 +287,4 @@ jobs: cmake -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror=vla" -DBUILD_BENCHMARKS=ON -DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON -DCMAKE_PREFIX_PATH=/opt/rocm -DKokkos_ENABLE_DEPRECATED_CODE_3=OFF -DKokkos_ENABLE_DEPRECATED_CODE_4=OFF -DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF /src make -j 2 VERBOSE=1 EOF - docker run -v ${PWD}:/src:ro ghcr.io/maison-de-la-simulation/ddc/test_env:${GITHUB_SHA:0:7} bash /src/run.sh + docker run -v ${PWD}:/src:ro ${{ needs.docker-build-test_env.outputs.test_env_image }} bash /src/run.sh