From 2e7d70dd0b56b77195ebf8f7bba51ec634664955 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Fri, 23 Jun 2023 16:20:20 -0500 Subject: [PATCH] ci: use Artifactory remote in nix workflow (#4556) There is now an Artifactory (thanks @shichengripple001 and team!) to hold dependency binaries for the builds. * Rewrite the `nix` workflow to use it and cut the time down to a mere 21 minutes. * This workflow should continue to work (just more slowly) for forks that do not have access to the Artifactory. --- .github/workflows/nix.yml | 53 +++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 53c75a9f6fd..706bdbe103b 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -1,6 +1,25 @@ name: nix on: [push, pull_request] +# This workflow has two job matrixes. +# They can be considered phases because the second matrix ("test") +# depends on the first ("dependencies"). +# +# The first phase has a job in the matrix for each combination of +# variables that affects dependency ABI: +# platform, compiler, and configuration. +# It creates a GitHub artifact holding the Conan profile, +# and builds and caches binaries for all the dependencies. +# If an Artifactory remote is configured, they are cached there. +# If not, they are added to the GitHub artifact. +# GitHub's "cache" action has a size limit (10 GB) that is too small +# to hold the binaries if they are built locally. +# We must use the "{upload,download}-artifact" actions instead. +# +# The second phase has a job in the matrix for each test configuration. +# It installs dependency binaries from the cache, whichever was used, +# and builds and tests rippled. + jobs: dependencies: @@ -31,6 +50,8 @@ jobs: env: build_dir: .build steps: + - name: checkout + uses: actions/checkout@v3 - name: check environment run: | echo ${PATH} | tr ':' '\n' @@ -38,6 +59,8 @@ jobs: cmake --version env - name: configure Conan + env: + CONAN_URL: http://18.143.149.228:8081/artifactory/api/conan/conan-non-prod run: | conan profile new default --detect conan profile update settings.compiler.cppstd=20 default @@ -47,19 +70,39 @@ jobs: conan profile update env.CC=${{ matrix.profile.cc }} default conan profile update env.CXX=${{ matrix.profile.cxx }} default conan profile update conf.tools.build:compiler_executables='{"c": "${{ matrix.profile.cc }}", "cpp": "${{ matrix.profile.cxx }}"}' default - - name: checkout - uses: actions/checkout@v3 - - name: dependencies + # Do not quote the URL. An empty string will be accepted (with + # a non-fatal warning), but a missing argument will not. + conan remote add ripple ${{ env.CONAN_URL }} --insert 0 + - name: try to authenticate to ripple Conan remote + id: remote + run: | + echo outcome=$(conan user --remote ripple ${{ secrets.CONAN_USERNAME }} --password ${{ secrets.CONAN_TOKEN }} && echo success || echo failure) | tee ${GITHUB_OUTPUT} + - name: archive profile + # Create this archive before dependencies are added to the local cache. + run: tar -czf conan.tar -C ~/.conan . + - name: list missing binaries + id: binaries + # Print the list of dependencies that would need to be built locally. + # A non-empty list means we have "failed" to cache binaries remotely. + run: | + echo missing=$(conan info . --build missing --json 2>/dev/null | grep '^\[') | tee ${GITHUB_OUTPUT} + - name: build dependencies + if: (steps.binaries.outputs.missing != '[]') uses: ./.github/actions/dependencies with: configuration: ${{ matrix.configuration }} - - name: archive cache + - name: upload dependencies to remote + if: (steps.binaries.outputs.missing != '[]') && (steps.remote.outputs.outcome == 'success') + run: conan upload --remote ripple '*' --all --parallel --confirm + - name: recreate archive with dependencies + if: (steps.binaries.outputs.missing != '[]') && (steps.remote.outputs.outcome == 'failure') run: tar -czf conan.tar -C ~/.conan . - - name: upload cache + - name: upload archive uses: actions/upload-artifact@v3 with: name: ${{ matrix.platform }}-${{ matrix.compiler }}-${{ matrix.configuration }} path: conan.tar + if-no-files-found: error test: