diff --git a/.github/workflows/Makefile b/.github/workflows/Makefile index fc08020a1..3f13702ef 100644 --- a/.github/workflows/Makefile +++ b/.github/workflows/Makefile @@ -14,6 +14,7 @@ export YSPATH := $(shell pwd -P)/ys build: $(TARGET_FILES) + test: force build @git diff --exit-code .*.yml && \ echo -e '\nPASS - No normative changes to .github/workflows/*.yml' diff --git a/.github/workflows/bash/benchmarks-vars-1.bash b/.github/workflows/bash/benchmarks-vars-1.bash deleted file mode 100644 index 2b69d1205..000000000 --- a/.github/workflows/bash/benchmarks-vars-1.bash +++ /dev/null @@ -1,7 +0,0 @@ -# https://github.community/t/how-to-get-just-the-tag-name/16241/11 -SRC_TAG=${GITHUB_REF#refs/tags/} -SRC_VERSION=${GITHUB_REF#refs/tags/v} -cat < vars.sh -export SRC_TAG=$SRC_TAG -export SRC_VERSION=$SRC_VERSION -EOF diff --git a/.github/workflows/bash/benchmarks-vars-2.bash b/.github/workflows/bash/benchmarks-vars-2.bash deleted file mode 100644 index 43f9154b1..000000000 --- a/.github/workflows/bash/benchmarks-vars-2.bash +++ /dev/null @@ -1,14 +0,0 @@ -set -x -branch_name=${GITHUB_REF#refs/heads/} -# builds triggered from PRs have the branch_name like this: refs/pull/150/merge -# so filter to eg pr0150_merge -branch_name=`echo $branch_name | sed "s:refs/pull/\([0-9]*\)/\(.*\):pr0\1_\2:"` -# sanitize the branch name; eg merge/foo-bar -> merge_foo_bar -branch_name=`echo $branch_name | sed 's:[/.-]:_:g'` -git config --global --add safe.directory $(pwd) -SRC_TAG=$(git describe || git rev-parse --short HEAD) # eg v0.2.0-110-gda837e0 -SRC_VERSION="${branch_name}-${SRC_TAG}" -cat < vars.sh -export SRC_TAG=$SRC_TAG -export SRC_VERSION=$SRC_VERSION -EOF diff --git a/.github/workflows/bash/gcc-checkout.bash b/.github/workflows/bash/gcc-checkout.bash deleted file mode 100644 index dd6c74143..000000000 --- a/.github/workflows/bash/gcc-checkout.bash +++ /dev/null @@ -1,11 +0,0 @@ -set -x -echo GITHUB_REF=$GITHUB_REF -echo GITHUB_HEAD_REF=$GITHUB_HEAD_REF -branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} # https://stackoverflow.com/questions/58033366 -echo branch=$branch -git init -q . -git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 -git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY -git fetch origin $branch -git reset --hard FETCH_HEAD -git submodule update --init --recursive diff --git a/.github/workflows/bash/gcc-configure.bash b/.github/workflows/bash/gcc-configure.bash deleted file mode 100644 index 62efab660..000000000 --- a/.github/workflows/bash/gcc-configure.bash +++ /dev/null @@ -1,6 +0,0 @@ -cmake -S . -B build_o2 \ - -DCMAKE_CXX_COMPILER=g++-${{matrix.gcc}} \ - -DCMAKE_C_COMPILER=gcc-${{matrix.gcc}} \ - -DCMAKE_CXX_FLAGS_RELEASE:STRING="-O2 -g -DNDEBUG" \ - -DRYML_BUILD_TESTS:BOOL=ON \ - -DRYML_DBG:BOOL=OFF diff --git a/.github/workflows/bash/release-save-vars.bash b/.github/workflows/bash/release-save-vars.bash deleted file mode 100644 index c6ab4cc45..000000000 --- a/.github/workflows/bash/release-save-vars.bash +++ /dev/null @@ -1,8 +0,0 @@ -source vars.sh -version_body=${{github.workspace}}/changelog/$SRC_VERSION.md -if [ ! -f $version_body ] ; then - echo "version body file was not found: $version_body" - exit 1 -fi -echo "VERSION=$SRC_VERSION >> $GITHUB_OUTPUT" -echo "VERSION_BODY=$version_body >> $GITHUB_OUTPUT" diff --git a/.github/workflows/bash/release-vars-1.bash b/.github/workflows/bash/release-vars-1.bash deleted file mode 100644 index 2b69d1205..000000000 --- a/.github/workflows/bash/release-vars-1.bash +++ /dev/null @@ -1,7 +0,0 @@ -# https://github.community/t/how-to-get-just-the-tag-name/16241/11 -SRC_TAG=${GITHUB_REF#refs/tags/} -SRC_VERSION=${GITHUB_REF#refs/tags/v} -cat < vars.sh -export SRC_TAG=$SRC_TAG -export SRC_VERSION=$SRC_VERSION -EOF diff --git a/.github/workflows/bash/release-vars-2.bash b/.github/workflows/bash/release-vars-2.bash deleted file mode 100644 index 7deeaa8cb..000000000 --- a/.github/workflows/bash/release-vars-2.bash +++ /dev/null @@ -1,13 +0,0 @@ -set -x -branch_name=${GITHUB_REF#refs/heads/} -# builds triggered from PRs have the branch_name like this: refs/pull/150/merge -# so filter to eg pr0150_merge -branch_name=`echo $branch_name | sed "s:refs/pull/\([0-9]*\)/\(.*\):pr0\1_\2:"` -# sanitize the branch name; eg merge/foo-bar -> merge_foo_bar -branch_name=`echo $branch_name | sed 's:[/.-]:_:g'` -SRC_TAG=$(git describe || git rev-parse --short HEAD) # eg v0.2.0-110-gda837e0 -SRC_VERSION="${branch_name}-${SRC_TAG}" -cat < vars.sh -export SRC_TAG=$SRC_TAG -export SRC_VERSION=$SRC_VERSION -EOF diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index f46f4d42c..3b488690b 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -21,7 +21,7 @@ jobs: gettag: runs-on: ubuntu-latest steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive @@ -29,37 +29,59 @@ jobs: - name: Variables (from tag) if: contains(github.ref, 'tags/v') run: | + set -exo pipefail # https://github.community/t/how-to-get-just-the-tag-name/16241/11 SRC_TAG=${GITHUB_REF#refs/tags/} SRC_VERSION=${GITHUB_REF#refs/tags/v} - cat < vars.sh + SRC_VERSION_BODY=`pwd`/changelog/$SRC_VERSION.md + if [ ! -f $SRC_VERSION_BODY ] ; then + echo "version body file was not found: $SRC_VERSION_BODY" + exit 1 + fi + cat <> vars.sh export SRC_TAG=$SRC_TAG export SRC_VERSION=$SRC_VERSION + export SRC_VERSION_BODY=$SRC_VERSION_BODY EOF - name: Variables (from commit, no tag) if: ${{ !contains(github.ref, 'tags/v') }} run: | - set -x + set -exo pipefail branch_name=${GITHUB_REF#refs/heads/} # builds triggered from PRs have the branch_name like this: refs/pull/150/merge # so filter to eg pr0150_merge branch_name=`echo $branch_name | sed "s:refs/pull/\([0-9]*\)/\(.*\):pr0\1_\2:"` # sanitize the branch name; eg merge/foo-bar -> merge_foo_bar branch_name=`echo $branch_name | sed 's:[/.-]:_:g'` - git config --global --add safe.directory $(pwd) SRC_TAG=$(git describe || git rev-parse --short HEAD) # eg v0.2.0-110-gda837e0 SRC_VERSION="${branch_name}-${SRC_TAG}" cat < vars.sh export SRC_TAG=$SRC_TAG export SRC_VERSION=$SRC_VERSION EOF - - name: Verify vars.sh - run: cat vars.sh ; source vars.sh ; echo $SRC_TAG ; echo $SRC_VERSION - name: Save vars.sh uses: actions/upload-artifact@v3 with: name: vars.sh path: ./vars.sh + - name: Show vars.sh + run: cat vars.sh + - name: Source vars.sh + run: source vars.sh + - name: Env (common) + run: | + source vars.sh + echo "SRC_TAG=$SRC_TAG" >> $GITHUB_ENV + echo "SRC_VERSION=$SRC_VERSION" >> $GITHUB_ENV + - name: Env (from tag) + if: contains(github.ref, 'tags/v') + run: | + echo "SRC_VERSION_BODY=$SRC_VERSION_BODY" >> $GITHUB_ENV + - name: Variables (from commit, no tag) + if: ${{ !contains(github.ref, 'tags/v') }} + run: echo 'nothing to do' + - name: Verify vars.sh + run: env | grep SRC benchmarks: name: bm/c++${{matrix.std}}/${{matrix.cxx}}/${{matrix.bt}} needs: gettag @@ -115,18 +137,36 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 - - name: install requirements - run: source .github/reqs.sh && c4_install_test_requirements $OS - name: Download vars.sh uses: actions/download-artifact@v3 with: name: vars.sh path: ./ + - name: Show vars.sh + run: cat vars.sh + - name: Source vars.sh + run: source vars.sh + - name: Env (common) + run: | + source vars.sh + echo "SRC_TAG=$SRC_TAG" >> $GITHUB_ENV + echo "SRC_VERSION=$SRC_VERSION" >> $GITHUB_ENV + - name: Env (from tag) + if: contains(github.ref, 'tags/v') + run: | + echo "SRC_VERSION_BODY=$SRC_VERSION_BODY" >> $GITHUB_ENV + - name: Variables (from commit, no tag) + if: ${{ !contains(github.ref, 'tags/v') }} + run: echo 'nothing to do' + - name: Verify vars.sh + run: env | grep SRC + - name: install requirements + run: source .github/reqs.sh && c4_install_test_requirements $OS - name: show info run: source .github/setenv.sh && c4_show_info - name: Install python 3.10 for plotting @@ -142,38 +182,46 @@ jobs: pip install -v -r ext/c4core/cmake/bm-xp/requirements.txt python -c 'import munch ; print("ok!") ; exit(0)' echo $? + - name: set build env vars + run: | + echo "NUM_JOBS_BUILD=1 >> $GITHUB_ENV + echo "CMAKE_FLAGS=\"-DPython_EXECUTABLE=$(which python)\"" >> $GITHUB_ENV + - name: check build env vars + run: | + echo NUM_JOBS_BUILD=$NUM_JOBS_BUILD" + echo "CMAKE_FLAGS=\"$CMAKE_FLAGS\"" - name: shared64-configure------------------------------------------------- - run: export CMAKE_FLAGS="-DPython_EXECUTABLE=$(which python)" && source .github/setenv.sh && c4_cfg_test shared64 + run: source .github/setenv.sh && c4_cfg_test shared64 - name: shared64-build run: source .github/setenv.sh && c4_build_target shared64 ryml-bm-build - name: shared64-run - run: export NUM_JOBS_BUILD=1 && source .github/setenv.sh && c4_run_target shared64 ryml-bm-run + run: source .github/setenv.sh && c4_run_target shared64 ryml-bm-run - name: shared64-plot - run: export NUM_JOBS_BUILD=1 && source .github/setenv.sh && c4_run_target shared64 ryml-bm-plot + run: source .github/setenv.sh && c4_run_target shared64 ryml-bm-plot - name: static64-configure------------------------------------------------- - run: export CMAKE_FLAGS="-DPython_EXECUTABLE=$(which python)" && source .github/setenv.sh && c4_cfg_test static64 + run: source .github/setenv.sh && c4_cfg_test static64 - name: static64-build run: source .github/setenv.sh && c4_build_target static64 ryml-bm-build - name: static64-run - run: export NUM_JOBS_BUILD=1 && source .github/setenv.sh && c4_run_target static64 ryml-bm-run + run: source .github/setenv.sh && c4_run_target static64 ryml-bm-run - name: static64-plot - run: export NUM_JOBS_BUILD=1 && source .github/setenv.sh && c4_run_target static64 ryml-bm-plot + run: source .github/setenv.sh && c4_run_target static64 ryml-bm-plot - name: static32-configure------------------------------------------------- - run: export CMAKE_FLAGS="-DPython_EXECUTABLE=$(which python)" && source .github/setenv.sh && c4_cfg_test static32 + run: source .github/setenv.sh && c4_cfg_test static32 - name: static32-build run: source .github/setenv.sh && c4_build_target static32 ryml-bm-build - name: static32-run - run: export NUM_JOBS_BUILD=1 && source .github/setenv.sh && c4_run_target static32 ryml-bm-run + run: source .github/setenv.sh && c4_run_target static32 ryml-bm-run - name: static32-plot - run: export NUM_JOBS_BUILD=1 && source .github/setenv.sh && c4_run_target static32 ryml-bm-plot + run: source .github/setenv.sh && c4_run_target static32 ryml-bm-plot - name: shared32-configure------------------------------------------------- - run: export CMAKE_FLAGS="-DPython_EXECUTABLE=$(which python)" && source .github/setenv.sh && c4_cfg_test shared32 + run: source .github/setenv.sh && c4_cfg_test shared32 - name: shared32-build run: source .github/setenv.sh && c4_build_target shared32 ryml-bm-build - name: shared32-run - run: export NUM_JOBS_BUILD=1 && source .github/setenv.sh && c4_run_target shared32 ryml-bm-run + run: source .github/setenv.sh && c4_run_target shared32 ryml-bm-run - name: shared32-plot - run: export NUM_JOBS_BUILD=1 && source .github/setenv.sh && c4_run_target shared32 ryml-bm-plot + run: source .github/setenv.sh && c4_run_target shared32 ryml-bm-plot - name: gather benchmark results run: | set -x diff --git a/.github/workflows/benchmarks.ys b/.github/workflows/benchmarks.ys index ca00d8388..224e1f1b8 100644 --- a/.github/workflows/benchmarks.ys +++ b/.github/workflows/benchmarks.ys @@ -8,21 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - :: checkout-action - - name: Variables (from tag) - if: contains(github.ref, 'tags/v') - run:: bash('benchmarks-vars-1') - - name: Variables (from commit, no tag) - if: ${{ !contains(github.ref, 'tags/v') }} - run:: bash('benchmarks-vars-2') - - name: Verify vars.sh - run: - cat vars.sh ; - source vars.sh ; - echo $SRC_TAG ; - echo $SRC_VERSION - - name: Save vars.sh - uses: actions/upload-artifact@v3 - with: {name: vars.sh, path: ./vars.sh} + - :: version-discover benchmarks: name: bm/c++${{matrix.std}}/${{matrix.cxx}}/${{matrix.bt}} @@ -32,9 +18,7 @@ jobs: strategy: fail-fast: false matrix: - item =: - \({:std %1, :cxx %2, :bt 'Release', - :os %3, :bitlinks 'static64 static32'}) + item =: \({:std %1, :cxx %2, :bt 'Release', :os %3, :bitlinks 'static64 static32'}) include: - ! item(11 'g++-10' 'ubuntu-20.04') - ! item(17 'g++-10' 'ubuntu-20.04') @@ -43,17 +27,13 @@ jobs: - ! item(20 'vs2019' 'windows-2019') #- ! item(17 'vs2019' 'windows-2022') #- ! item(20 'vs2019' 'windows-2022') - - {std: 17, cxx: xcode, - xcver: 15, bt: Release, - os: macos-13, bitlinks: static64} + - {std: 17, cxx: xcode, xcver: 15, bt: Release, os: macos-13, bitlinks: static64} env:: -{'BM' 'ON'} + load('share/env.yaml') steps: - :: checkout-action + - :: version-get-vars - name: install requirements run: source .github/reqs.sh && c4_install_test_requirements $OS - - name: Download vars.sh - uses: actions/download-artifact@v3 - with: {name: vars.sh, path: ./} - name: show info run: source .github/setenv.sh && c4_show_info - name: Install python 3.10 for plotting @@ -61,56 +41,48 @@ jobs: with: { python-version: '3.10' } - name: install benchmark plotting dependencies run:: bash('benchmarks-install') + - name: set build env vars + run: | + echo "NUM_JOBS_BUILD=1 >> $GITHUB_ENV + echo "CMAKE_FLAGS=\"-DPython_EXECUTABLE=$(which python)\"" >> $GITHUB_ENV + - name: check build env vars + run: | + echo NUM_JOBS_BUILD=$NUM_JOBS_BUILD" + echo "CMAKE_FLAGS=\"$CMAKE_FLAGS\"" - name: shared64-configure------------------------------------------------- - run: export CMAKE_FLAGS="-DPython_EXECUTABLE=$(which python)" && - source .github/setenv.sh && c4_cfg_test shared64 + run: source .github/setenv.sh && c4_cfg_test shared64 - name: shared64-build run: source .github/setenv.sh && c4_build_target shared64 ryml-bm-build - name: shared64-run - run: export NUM_JOBS_BUILD=1 && - source .github/setenv.sh && c4_run_target shared64 ryml-bm-run + run: source .github/setenv.sh && c4_run_target shared64 ryml-bm-run - name: shared64-plot - run: export NUM_JOBS_BUILD=1 && - source .github/setenv.sh && c4_run_target shared64 ryml-bm-plot - + run: source .github/setenv.sh && c4_run_target shared64 ryml-bm-plot - name: static64-configure------------------------------------------------- - run: export CMAKE_FLAGS="-DPython_EXECUTABLE=$(which python)" && - source .github/setenv.sh && c4_cfg_test static64 + run: source .github/setenv.sh && c4_cfg_test static64 - name: static64-build run: source .github/setenv.sh && c4_build_target static64 ryml-bm-build - name: static64-run - run: export NUM_JOBS_BUILD=1 && - source .github/setenv.sh && c4_run_target static64 ryml-bm-run + run: source .github/setenv.sh && c4_run_target static64 ryml-bm-run - name: static64-plot - run: export NUM_JOBS_BUILD=1 && - source .github/setenv.sh && c4_run_target static64 ryml-bm-plot - + run: source .github/setenv.sh && c4_run_target static64 ryml-bm-plot - name: static32-configure------------------------------------------------- - run: export CMAKE_FLAGS="-DPython_EXECUTABLE=$(which python)" && - source .github/setenv.sh && c4_cfg_test static32 + run: source .github/setenv.sh && c4_cfg_test static32 - name: static32-build run: source .github/setenv.sh && c4_build_target static32 ryml-bm-build - name: static32-run - run: export NUM_JOBS_BUILD=1 && - source .github/setenv.sh && c4_run_target static32 ryml-bm-run + run: source .github/setenv.sh && c4_run_target static32 ryml-bm-run - name: static32-plot - run: export NUM_JOBS_BUILD=1 && - source .github/setenv.sh && c4_run_target static32 ryml-bm-plot - + run: source .github/setenv.sh && c4_run_target static32 ryml-bm-plot - name: shared32-configure------------------------------------------------- - run: export CMAKE_FLAGS="-DPython_EXECUTABLE=$(which python)" && - source .github/setenv.sh && c4_cfg_test shared32 + run: source .github/setenv.sh && c4_cfg_test shared32 - name: shared32-build run: source .github/setenv.sh && c4_build_target shared32 ryml-bm-build - name: shared32-run - run: export NUM_JOBS_BUILD=1 && - source .github/setenv.sh && c4_run_target shared32 ryml-bm-run + run: source .github/setenv.sh && c4_run_target shared32 ryml-bm-run - name: shared32-plot - run: export NUM_JOBS_BUILD=1 && - source .github/setenv.sh && c4_run_target shared32 ryml-bm-plot + run: source .github/setenv.sh && c4_run_target shared32 ryml-bm-plot - name: gather benchmark results run:: bash('benchmarks-run') - - name: upload benchmark result artifacts uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 7148977ab..ba41a32d0 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -57,7 +57,7 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (action + docker) uses: actions/checkout@v4 with: submodules: recursive @@ -138,7 +138,7 @@ jobs: OS: ${{matrix.os}} CMAKE_FLAGS: -DRYML_WITH_TAB_TOKENS=ON steps: - - name: checkout + - name: checkout (action + docker) uses: actions/checkout@v4 with: submodules: recursive @@ -219,7 +219,7 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (action + docker) uses: actions/checkout@v4 with: submodules: recursive @@ -433,22 +433,54 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (manually) run: | - set -xe - env + set -xeo pipefail + env | sort echo GITHUB_SERVER_URL=$GITHUB_SERVER_URL echo GITHUB_REPOSITORY=$GITHUB_REPOSITORY echo GITHUB_REF=$GITHUB_REF + echo GITHUB_REF_NAME=$GITHUB_REF_NAME echo GITHUB_HEAD_REF=$GITHUB_HEAD_REF - branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} # https://stackoverflow.com/questions/58033366 + repo=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # check the branch + # https://stackoverflow.com/questions/58033366 + branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} echo branch=$branch + # does the branch exist in the repo? + if [ -z "$(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + # refs/pull/485/merge -> pull/485/head + branch=`echo ${GITHUB_REF#refs/} | sed -e 's:merge:head:g'` + echo "... falling back to $branch" + # does the fallback exist? + if [ -z "(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + exit 1 + else + echo "branch $branch exists on $repo" + localbranch=$(echo $branch | sed -e 's@[/:]@_@g') + branch=$branch:$localbranch + echo "naming locally as $branch" + fi + fi + # finally, create the local repo git init -q . - git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # needed for running in the docker image. + # see https://github.com/actions/checkout/issues/1169 + git config --system --add safe.directory '*' + # finally, do it! + git remote add origin $repo git fetch origin $branch git reset --hard FETCH_HEAD git submodule update --init --recursive + # show the log + git log --graph --date=relative --date-order --color=always \ + --pretty='%C(yellow)%h %C(cyan)%cd %Cblue%aN%C(auto)%d %Creset%s' \ + | head -30 \ + || echo -n + # show the last commit + git log --name-status HEAD^..HEAD - run: c4core-install ${{matrix.cxx}} - name: show info run: source .github/setenv.sh && c4_show_info @@ -571,7 +603,7 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (action + docker) uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/clang.ys b/.github/workflows/clang.ys index 069291f9d..c479b8bf0 100644 --- a/.github/workflows/clang.ys +++ b/.github/workflows/clang.ys @@ -50,14 +50,12 @@ jobs: #---------------------------------------------------------------------------- clang_extended: :: setup-job('clang') - name: "extended/${{matrix.cxx}}/c++${{matrix.std}}/\ - ${{matrix.bt}}/vg${{matrix.vg}}" + name: extended/${{matrix.cxx}}/c++${{matrix.std}}/${{matrix.bt}}/vg${{matrix.vg}} :: runs-on-docker-c4core('${{matrix.img}}') strategy: fail-fast: false matrix: - item =: \({:std 11, :cxx "clang++-$a(%1)" - :bt %2, :vg 'on', :img "$a(%3)"}) + item =: \({:std 11, :cxx "clang++-$a(%1)", :bt %2, :vg 'on', :img "$a(%3)"}) include: - ! item(17 'Debug' '22.04') - ! item(17 'Release' '22.04') diff --git a/.github/workflows/clang_tidy.yml b/.github/workflows/clang_tidy.yml index 360f48da1..02a75aae5 100644 --- a/.github/workflows/clang_tidy.yml +++ b/.github/workflows/clang_tidy.yml @@ -81,7 +81,7 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (action + docker) uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b742db026..c0b07820f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -24,7 +24,7 @@ jobs: (!contains(github.event.head_commit.message, 'skip coverage')) || contains(github.event.head_commit.message, 'only coverage') continue-on-error: true - name: coverage/c++${{matrix.std}}${{matrix.cmk}} + name: coverage/c++${{matrix.std}}${{matrix.namesfx}} runs-on: ${{matrix.os}} strategy: fail-fast: false @@ -43,11 +43,13 @@ jobs: bt: Coverage os: ubuntu-20.04 cmk: -DRYML_DBG=ON + namesfx: /dbg - std: 17 cxx: g++-9 bt: Coverage os: ubuntu-20.04 cmk: -DRYML_DBG=ON + namesfx: /dbg env: STD: ${{matrix.std}} CXX_: ${{matrix.cxx}} @@ -61,10 +63,11 @@ jobs: CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} COVERALLS_REPO_TOKEN: ${{secrets.COVERALLS_REPO_TOKEN}} steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive + fetch-depth: 0 - name: install requirements run: source .github/reqs.sh && c4_install_test_requirements $OS - name: show info @@ -80,7 +83,7 @@ jobs: with: name: coverage-static64 path: | - build/static64/lcov/ + build/static64/lcov build/static64/coverage3-final_filtered.lcov - name: static64-submit-codecov run: source .github/setenv.sh && c4_submit_coverage static64 codecov diff --git a/.github/workflows/coverage.ys b/.github/workflows/coverage.ys index 7bc14efb2..8568d62b6 100644 --- a/.github/workflows/coverage.ys +++ b/.github/workflows/coverage.ys @@ -6,7 +6,7 @@ jobs: coverage: :: setup-job('coverage') - name: coverage/c++${{matrix.std}}${{matrix.cmk}} + name: coverage/c++${{matrix.std}}${{matrix.namesfx}} runs-on: ${{matrix.os}} strategy: fail-fast: false @@ -16,8 +16,8 @@ jobs: - ! item(11) - ! item(17) # test also with the debug code enabled - - ! item(11) + {:cmk '-DRYML_DBG=ON'} - - ! item(17) + {:cmk '-DRYML_DBG=ON'} + - ! item(11) + {:cmk '-DRYML_DBG=ON', :namesfx '/dbg'} + - ! item(17) + {:cmk '-DRYML_DBG=ON', :namesfx '/dbg'} env: !:merge* - ! load('share/env.yaml') - CMAKE_FLAGS: ${{matrix.cmk}} @@ -27,11 +27,8 @@ jobs: # https://github.com/lemurheavy/coveralls-public/issues/1665 # https://docs.coveralls.io/parallel-build-webhook # COVERALLS_PARALLEL: true - steps: - - name: checkout - uses: actions/checkout@v4 - with: {submodules: recursive} + - :: checkout-action - name: install requirements run: source .github/reqs.sh && c4_install_test_requirements $OS - name: show info @@ -47,18 +44,16 @@ jobs: with: name: coverage-static64 path: | - build/static64/lcov/ + build/static64/lcov build/static64/coverage3-final_filtered.lcov - name: static64-submit-codecov run: source .github/setenv.sh && c4_submit_coverage static64 codecov - # Coveralls disabled: # https://github.com/lemurheavy/coveralls-public/issues/1665 #- name: static64-submit-coveralls # run: if [ ${{matrix.std}} == 17 ] ; # then ( source .github/setenv.sh && # c4_submit_coverage static64 coveralls ) ; fi - - name: static32-configure------------------------------------------------- run: source .github/setenv.sh && c4_cfg_test static32 - name: static32-build @@ -74,7 +69,6 @@ jobs: build/static32/coverage3-final_filtered.lcov - name: static32-submit-codecov run: source .github/setenv.sh && c4_submit_coverage static32 codecov - # Coveralls disabled: # https://github.com/lemurheavy/coveralls-public/issues/1665 #- name: static32-submit-coveralls diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml index 02d2f5fb4..b413da227 100644 --- a/.github/workflows/gcc.yml +++ b/.github/workflows/gcc.yml @@ -81,22 +81,54 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (manually) run: | - set -xe - env + set -xeo pipefail + env | sort echo GITHUB_SERVER_URL=$GITHUB_SERVER_URL echo GITHUB_REPOSITORY=$GITHUB_REPOSITORY echo GITHUB_REF=$GITHUB_REF + echo GITHUB_REF_NAME=$GITHUB_REF_NAME echo GITHUB_HEAD_REF=$GITHUB_HEAD_REF - branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} # https://stackoverflow.com/questions/58033366 + repo=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # check the branch + # https://stackoverflow.com/questions/58033366 + branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} echo branch=$branch + # does the branch exist in the repo? + if [ -z "$(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + # refs/pull/485/merge -> pull/485/head + branch=`echo ${GITHUB_REF#refs/} | sed -e 's:merge:head:g'` + echo "... falling back to $branch" + # does the fallback exist? + if [ -z "(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + exit 1 + else + echo "branch $branch exists on $repo" + localbranch=$(echo $branch | sed -e 's@[/:]@_@g') + branch=$branch:$localbranch + echo "naming locally as $branch" + fi + fi + # finally, create the local repo git init -q . - git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # needed for running in the docker image. + # see https://github.com/actions/checkout/issues/1169 + git config --system --add safe.directory '*' + # finally, do it! + git remote add origin $repo git fetch origin $branch git reset --hard FETCH_HEAD git submodule update --init --recursive + # show the log + git log --graph --date=relative --date-order --color=always \ + --pretty='%C(yellow)%h %C(cyan)%cd %Cblue%aN%C(auto)%d %Creset%s' \ + | head -30 \ + || echo -n + # show the last commit + git log --name-status HEAD^..HEAD - run: c4core-install ${{matrix.cxx}} - name: show info run: source .github/setenv.sh && c4_show_info @@ -158,7 +190,7 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (action + docker) uses: actions/checkout@v4 with: submodules: recursive @@ -243,22 +275,54 @@ jobs: OS: ${{matrix.os}} CMAKE_FLAGS: -DRYML_WITH_TAB_TOKENS=ON steps: - - name: checkout + - name: checkout (manually) run: | - set -xe - env + set -xeo pipefail + env | sort echo GITHUB_SERVER_URL=$GITHUB_SERVER_URL echo GITHUB_REPOSITORY=$GITHUB_REPOSITORY echo GITHUB_REF=$GITHUB_REF + echo GITHUB_REF_NAME=$GITHUB_REF_NAME echo GITHUB_HEAD_REF=$GITHUB_HEAD_REF - branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} # https://stackoverflow.com/questions/58033366 + repo=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # check the branch + # https://stackoverflow.com/questions/58033366 + branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} echo branch=$branch + # does the branch exist in the repo? + if [ -z "$(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + # refs/pull/485/merge -> pull/485/head + branch=`echo ${GITHUB_REF#refs/} | sed -e 's:merge:head:g'` + echo "... falling back to $branch" + # does the fallback exist? + if [ -z "(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + exit 1 + else + echo "branch $branch exists on $repo" + localbranch=$(echo $branch | sed -e 's@[/:]@_@g') + branch=$branch:$localbranch + echo "naming locally as $branch" + fi + fi + # finally, create the local repo git init -q . - git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # needed for running in the docker image. + # see https://github.com/actions/checkout/issues/1169 + git config --system --add safe.directory '*' + # finally, do it! + git remote add origin $repo git fetch origin $branch git reset --hard FETCH_HEAD git submodule update --init --recursive + # show the log + git log --graph --date=relative --date-order --color=always \ + --pretty='%C(yellow)%h %C(cyan)%cd %Cblue%aN%C(auto)%d %Creset%s' \ + | head -30 \ + || echo -n + # show the last commit + git log --name-status HEAD^..HEAD - run: c4core-install ${{matrix.cxx}} - name: show info run: source .github/setenv.sh && c4_show_info @@ -338,22 +402,54 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (manually) run: | - set -xe - env + set -xeo pipefail + env | sort echo GITHUB_SERVER_URL=$GITHUB_SERVER_URL echo GITHUB_REPOSITORY=$GITHUB_REPOSITORY echo GITHUB_REF=$GITHUB_REF + echo GITHUB_REF_NAME=$GITHUB_REF_NAME echo GITHUB_HEAD_REF=$GITHUB_HEAD_REF - branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} # https://stackoverflow.com/questions/58033366 + repo=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # check the branch + # https://stackoverflow.com/questions/58033366 + branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} echo branch=$branch + # does the branch exist in the repo? + if [ -z "$(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + # refs/pull/485/merge -> pull/485/head + branch=`echo ${GITHUB_REF#refs/} | sed -e 's:merge:head:g'` + echo "... falling back to $branch" + # does the fallback exist? + if [ -z "(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + exit 1 + else + echo "branch $branch exists on $repo" + localbranch=$(echo $branch | sed -e 's@[/:]@_@g') + branch=$branch:$localbranch + echo "naming locally as $branch" + fi + fi + # finally, create the local repo git init -q . - git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # needed for running in the docker image. + # see https://github.com/actions/checkout/issues/1169 + git config --system --add safe.directory '*' + # finally, do it! + git remote add origin $repo git fetch origin $branch git reset --hard FETCH_HEAD git submodule update --init --recursive + # show the log + git log --graph --date=relative --date-order --color=always \ + --pretty='%C(yellow)%h %C(cyan)%cd %Cblue%aN%C(auto)%d %Creset%s' \ + | head -30 \ + || echo -n + # show the last commit + git log --name-status HEAD^..HEAD - run: c4core-install ${{matrix.cxx}} - name: show info run: source .github/setenv.sh && c4_show_info @@ -395,7 +491,7 @@ jobs: (!contains(github.event.head_commit.message, 'skip gcc')) || contains(github.event.head_commit.message, 'only gcc') continue-on-error: true - name: gcc_extended/${{matrix.cxx}}/c++${{matrix.std}}/${{matrix.bt}}/vg${{matrix.vg}} + name: extended/${{matrix.cxx}}/c++${{matrix.std}}/${{matrix.bt}}/vg${{matrix.vg}} runs-on: ubuntu-latest container: ghcr.io/biojppm/c4core/ubuntu${{matrix.img}}:latest strategy: @@ -540,22 +636,54 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (manually) run: | - set -xe - env + set -xeo pipefail + env | sort echo GITHUB_SERVER_URL=$GITHUB_SERVER_URL echo GITHUB_REPOSITORY=$GITHUB_REPOSITORY echo GITHUB_REF=$GITHUB_REF + echo GITHUB_REF_NAME=$GITHUB_REF_NAME echo GITHUB_HEAD_REF=$GITHUB_HEAD_REF - branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} # https://stackoverflow.com/questions/58033366 + repo=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # check the branch + # https://stackoverflow.com/questions/58033366 + branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} echo branch=$branch + # does the branch exist in the repo? + if [ -z "$(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + # refs/pull/485/merge -> pull/485/head + branch=`echo ${GITHUB_REF#refs/} | sed -e 's:merge:head:g'` + echo "... falling back to $branch" + # does the fallback exist? + if [ -z "(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + exit 1 + else + echo "branch $branch exists on $repo" + localbranch=$(echo $branch | sed -e 's@[/:]@_@g') + branch=$branch:$localbranch + echo "naming locally as $branch" + fi + fi + # finally, create the local repo git init -q . - git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # needed for running in the docker image. + # see https://github.com/actions/checkout/issues/1169 + git config --system --add safe.directory '*' + # finally, do it! + git remote add origin $repo git fetch origin $branch git reset --hard FETCH_HEAD git submodule update --init --recursive + # show the log + git log --graph --date=relative --date-order --color=always \ + --pretty='%C(yellow)%h %C(cyan)%cd %Cblue%aN%C(auto)%d %Creset%s' \ + | head -30 \ + || echo -n + # show the last commit + git log --name-status HEAD^..HEAD - run: c4core-install ${{matrix.cxx}} - name: show info run: source .github/setenv.sh && c4_show_info @@ -597,7 +725,7 @@ jobs: (!contains(github.event.head_commit.message, 'skip gcc')) || contains(github.event.head_commit.message, 'only gcc') continue-on-error: true - name: gccsan/${{matrix.cxx}}/c++${{matrix.std}}/${{matrix.bt}}/vg${{matrix.vg}} + name: gccsan/${{matrix.bt}}/${{matrix.cxx}}/c++${{matrix.std}} runs-on: ubuntu-latest container: ghcr.io/biojppm/c4core/ubuntu22.04:latest strategy: @@ -678,7 +806,7 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (action + docker) uses: actions/checkout@v4 with: submodules: recursive @@ -734,34 +862,28 @@ jobs: include: - std: 11 bt: Debug - toolchain: ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake cxx: arm-linux-gnueabihf-gcc - os: ubuntu-20.04 + toolchain: ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake - std: 11 bt: Release - toolchain: ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake cxx: arm-linux-gnueabihf-gcc - os: ubuntu-20.04 + toolchain: ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake - std: 14 bt: Debug - toolchain: ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake cxx: arm-linux-gnueabihf-gcc - os: ubuntu-20.04 + toolchain: ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake - std: 14 bt: Release - toolchain: ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake cxx: arm-linux-gnueabihf-gcc - os: ubuntu-20.04 + toolchain: ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake - std: 17 bt: Debug - toolchain: ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake cxx: arm-linux-gnueabihf-gcc - os: ubuntu-20.04 + toolchain: ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake - std: 17 bt: Release - toolchain: ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake cxx: arm-linux-gnueabihf-gcc - os: ubuntu-20.04 + toolchain: ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake env: TOOLCHAIN: ${{matrix.toolchain}} STD: ${{matrix.std}} @@ -773,22 +895,54 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (manually) run: | - set -xe - env + set -xeo pipefail + env | sort echo GITHUB_SERVER_URL=$GITHUB_SERVER_URL echo GITHUB_REPOSITORY=$GITHUB_REPOSITORY echo GITHUB_REF=$GITHUB_REF + echo GITHUB_REF_NAME=$GITHUB_REF_NAME echo GITHUB_HEAD_REF=$GITHUB_HEAD_REF - branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} # https://stackoverflow.com/questions/58033366 + repo=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # check the branch + # https://stackoverflow.com/questions/58033366 + branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} echo branch=$branch + # does the branch exist in the repo? + if [ -z "$(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + # refs/pull/485/merge -> pull/485/head + branch=`echo ${GITHUB_REF#refs/} | sed -e 's:merge:head:g'` + echo "... falling back to $branch" + # does the fallback exist? + if [ -z "(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + exit 1 + else + echo "branch $branch exists on $repo" + localbranch=$(echo $branch | sed -e 's@[/:]@_@g') + branch=$branch:$localbranch + echo "naming locally as $branch" + fi + fi + # finally, create the local repo git init -q . - git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # needed for running in the docker image. + # see https://github.com/actions/checkout/issues/1169 + git config --system --add safe.directory '*' + # finally, do it! + git remote add origin $repo git fetch origin $branch git reset --hard FETCH_HEAD git submodule update --init --recursive + # show the log + git log --graph --date=relative --date-order --color=always \ + --pretty='%C(yellow)%h %C(cyan)%cd %Cblue%aN%C(auto)%d %Creset%s' \ + | head -30 \ + || echo -n + # show the last commit + git log --name-status HEAD^..HEAD - name: install gcc-arm-linux-gnueabihf run: c4core-install arm-linux-gnueabihf; c4core-install qemu - name: show info diff --git a/.github/workflows/gcc.ys b/.github/workflows/gcc.ys index c0ffe528e..06869a538 100644 --- a/.github/workflows/gcc.ys +++ b/.github/workflows/gcc.ys @@ -4,6 +4,7 @@ :: workflow-setup() jobs: + #---------------------------------------------------------------------------- gcc_canary: :: setup-job('gcc') @@ -43,7 +44,13 @@ jobs: - name: show info run: source .github/setenv.sh && c4_show_info - name: configure - run:: bash('gcc-configure') + run: | + cmake -S . -B build_o2 \ + -DCMAKE_CXX_COMPILER=g++-${{matrix.gcc}} \ + -DCMAKE_C_COMPILER=gcc-${{matrix.gcc}} \ + -DCMAKE_CXX_FLAGS_RELEASE:STRING="-O2 -g -DNDEBUG" \ + -DRYML_BUILD_TESTS:BOOL=ON \ + -DRYML_DBG:BOOL=OFF - name: build run: cmake --build build_o2 --target ryml-test-build -j --verbose - name: run @@ -82,9 +89,7 @@ jobs: #---------------------------------------------------------------------------- gcc_extended: :: setup-job('gcc') - name:: - -'gcc_extended/${{matrix.cxx}}/c++${{matrix.std}}/' + - '${{matrix.bt}}/vg${{matrix.vg}}' + name: extended/${{matrix.cxx}}/c++${{matrix.std}}/${{matrix.bt}}/vg${{matrix.vg}} :: runs-on-docker-c4core('${{matrix.img}}') strategy: fail-fast: false @@ -129,8 +134,7 @@ jobs: #---------------------------------------------------------------------------- gccsan: :: setup-job('gcc') - name: "gccsan/${{matrix.cxx}}/c++${{matrix.std}}/\ - ${{matrix.bt}}/vg${{matrix.vg}}" + name: gccsan/${{matrix.bt}}/${{matrix.cxx}}/c++${{matrix.std}} :: runs-on-docker-c4core('22.04') strategy: fail-fast: false @@ -146,14 +150,13 @@ jobs: #---------------------------------------------------------------------------- arm: :: setup-job('gcc') + runs-on-docker-c4core('18.04') - runs-on: ubuntu-latest + name: arm/c++${{matrix.cxx}}/${{matrix.bt}} strategy: fail-fast: false matrix: item =: - \({:std %1, :bt %2, - :toolchain 'ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake', - :cxx 'arm-linux-gnueabihf-gcc', :os 'ubuntu-20.04'}) + \({:std %1, :bt %2, :cxx 'arm-linux-gnueabihf-gcc', + :toolchain 'ext/c4core/cmake/Toolchain-Arm-ubuntu.cmake'}) include: # these jobs take much longer, so run only one bitlink pair per job to # profit from parallelism diff --git a/.github/workflows/macosx.yml b/.github/workflows/macosx.yml index 5c54432ce..bb69113af 100644 --- a/.github/workflows/macosx.yml +++ b/.github/workflows/macosx.yml @@ -79,7 +79,7 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/rarearchs.yml b/.github/workflows/rarearchs.yml index 8d6aca4fd..b4350c89f 100644 --- a/.github/workflows/rarearchs.yml +++ b/.github/workflows/rarearchs.yml @@ -85,7 +85,7 @@ jobs: bt: Release arch: s390x steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 001fbcedc..b33726c4d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,7 @@ jobs: continue-on-error: false runs-on: ubuntu-latest steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive @@ -39,17 +39,24 @@ jobs: - name: Variables (from tag) if: contains(github.ref, 'tags/v') run: | + set -exo pipefail # https://github.community/t/how-to-get-just-the-tag-name/16241/11 SRC_TAG=${GITHUB_REF#refs/tags/} SRC_VERSION=${GITHUB_REF#refs/tags/v} - cat < vars.sh + SRC_VERSION_BODY=`pwd`/changelog/$SRC_VERSION.md + if [ ! -f $SRC_VERSION_BODY ] ; then + echo "version body file was not found: $SRC_VERSION_BODY" + exit 1 + fi + cat <> vars.sh export SRC_TAG=$SRC_TAG export SRC_VERSION=$SRC_VERSION + export SRC_VERSION_BODY=$SRC_VERSION_BODY EOF - name: Variables (from commit, no tag) if: ${{ !contains(github.ref, 'tags/v') }} run: | - set -x + set -exo pipefail branch_name=${GITHUB_REF#refs/heads/} # builds triggered from PRs have the branch_name like this: refs/pull/150/merge # so filter to eg pr0150_merge @@ -62,13 +69,29 @@ jobs: export SRC_TAG=$SRC_TAG export SRC_VERSION=$SRC_VERSION EOF - - name: Verify vars.sh - run: cat vars.sh ; source vars.sh ; echo $SRC_TAG ; echo $SRC_VERSION - name: Save vars.sh uses: actions/upload-artifact@v3 with: name: vars.sh path: ./vars.sh + - name: Show vars.sh + run: cat vars.sh + - name: Source vars.sh + run: source vars.sh + - name: Env (common) + run: | + source vars.sh + echo "SRC_TAG=$SRC_TAG" >> $GITHUB_ENV + echo "SRC_VERSION=$SRC_VERSION" >> $GITHUB_ENV + - name: Env (from tag) + if: contains(github.ref, 'tags/v') + run: | + echo "SRC_VERSION_BODY=$SRC_VERSION_BODY" >> $GITHUB_ENV + - name: Variables (from commit, no tag) + if: ${{ !contains(github.ref, 'tags/v') }} + run: echo 'nothing to do' + - name: Verify vars.sh + run: env | grep SRC src: if: | (!contains(github.event.head_commit.message, 'skip all')) || @@ -78,7 +101,7 @@ jobs: needs: gettag runs-on: ubuntu-latest steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive @@ -88,6 +111,24 @@ jobs: with: name: vars.sh path: ./ + - name: Show vars.sh + run: cat vars.sh + - name: Source vars.sh + run: source vars.sh + - name: Env (common) + run: | + source vars.sh + echo "SRC_TAG=$SRC_TAG" >> $GITHUB_ENV + echo "SRC_VERSION=$SRC_VERSION" >> $GITHUB_ENV + - name: Env (from tag) + if: contains(github.ref, 'tags/v') + run: | + echo "SRC_VERSION_BODY=$SRC_VERSION_BODY" >> $GITHUB_ENV + - name: Variables (from commit, no tag) + if: ${{ !contains(github.ref, 'tags/v') }} + run: echo 'nothing to do' + - name: Verify vars.sh + run: env | grep SRC - name: Install python 3.9 uses: actions/setup-python@v5 with: @@ -159,7 +200,7 @@ jobs: os: macos-13 cxx: xcode steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive @@ -169,6 +210,24 @@ jobs: with: name: vars.sh path: ./ + - name: Show vars.sh + run: cat vars.sh + - name: Source vars.sh + run: source vars.sh + - name: Env (common) + run: | + source vars.sh + echo "SRC_TAG=$SRC_TAG" >> $GITHUB_ENV + echo "SRC_VERSION=$SRC_VERSION" >> $GITHUB_ENV + - name: Env (from tag) + if: contains(github.ref, 'tags/v') + run: | + echo "SRC_VERSION_BODY=$SRC_VERSION_BODY" >> $GITHUB_ENV + - name: Variables (from commit, no tag) + if: ${{ !contains(github.ref, 'tags/v') }} + run: echo 'nothing to do' + - name: Verify vars.sh + run: env | grep SRC - name: install requirements run: source .github/reqs.sh && c4_install_test_requirements $OS - name: show info @@ -202,7 +261,7 @@ jobs: name: python/src runs-on: ubuntu-latest steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive @@ -328,7 +387,7 @@ jobs: osname: linux os: ubuntu-20.04 steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive @@ -381,7 +440,7 @@ jobs: - python_src - python_wheels steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive @@ -397,25 +456,30 @@ jobs: name: dist path: dist - name: Verify existing artifacts - run: ls -lFhp assets/; ls -lFhp dist/ - - name: Restore vars.sh - if: contains(github.ref, 'tags/v') + run: ls -lFhp assets/ dist/ + - name: Download vars.sh uses: actions/download-artifact@v3 with: name: vars.sh path: ./ - - name: Save vars for following steps - if: contains(github.ref, 'tags/v') - id: vars + - name: Show vars.sh + run: cat vars.sh + - name: Source vars.sh + run: source vars.sh + - name: Env (common) run: | source vars.sh - version_body=${{github.workspace}}/changelog/$SRC_VERSION.md - if [ ! -f $version_body ] ; then - echo "version body file was not found: $version_body" - exit 1 - fi - echo "VERSION=$SRC_VERSION >> $GITHUB_OUTPUT" - echo "VERSION_BODY=$version_body >> $GITHUB_OUTPUT" + echo "SRC_TAG=$SRC_TAG" >> $GITHUB_ENV + echo "SRC_VERSION=$SRC_VERSION" >> $GITHUB_ENV + - name: Env (from tag) + if: contains(github.ref, 'tags/v') + run: | + echo "SRC_VERSION_BODY=$SRC_VERSION_BODY" >> $GITHUB_ENV + - name: Variables (from commit, no tag) + if: ${{ !contains(github.ref, 'tags/v') }} + run: echo 'nothing to do' + - name: Verify vars.sh + run: env | grep SRC - name: Move Python packages to assets folder if: contains(github.ref, 'tags/v') run: mv -fv dist/*src.zip assets/. @@ -427,8 +491,8 @@ jobs: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} with: tag_name: ${{github.ref}} - release_name: Release ${{steps.vars.outputs.VERSION}} - body_path: ${{steps.vars.outputs.VERSION_BODY}} + release_name: Release ${{steps.vars.outputs.SRC_VERSION}} + body_path: ${{steps.vars.outputs.SRC_VERSION_BODY}} draft: true prerelease: ${{contains(github.ref, 'rc')}} - name: Upload assets to Github Release diff --git a/.github/workflows/release.ys b/.github/workflows/release.ys index d07c6255f..23ebc2a60 100644 --- a/.github/workflows/release.ys +++ b/.github/workflows/release.ys @@ -29,17 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - :: checkout-action - - name: Variables (from tag) - if: contains(github.ref, 'tags/v') - run:: bash('release-vars-1') - - name: Variables (from commit, no tag) - if: ${{ !contains(github.ref, 'tags/v') }} - run:: bash('release-vars-2') - - name: Verify vars.sh - run: cat vars.sh ; source vars.sh ; echo $SRC_TAG ; echo $SRC_VERSION - - name: Save vars.sh - uses: actions/upload-artifact@v3 - with: {name: vars.sh, path: ./vars.sh} + - :: version-discover #---------------------------------------------------------------------------- # create source packages @@ -50,15 +40,12 @@ jobs: runs-on: ubuntu-latest steps: - :: checkout-action - - name: Download vars.sh - uses: actions/download-artifact@v3 - with: {name: vars.sh, path: ./} + - :: version-get-vars - name: Install python 3.9 uses: actions/setup-python@v5 with: { python-version: 3.9 } - name: Install requirements - run: - sudo -E pip install git-archive-all + run: sudo -E pip install git-archive-all - name: Create source packages run:: bash('release-create-source-packages') - name: Save source artifacts @@ -107,9 +94,7 @@ jobs: gen: STGZ, mime: x-sh, os: macos-13, cxx: xcode} steps: - :: checkout-action - - name: Download vars.sh - uses: actions/download-artifact@v3 - with: {name: vars.sh, path: ./} + - :: version-get-vars - name: install requirements run: source .github/reqs.sh && c4_install_test_requirements $OS - name: show info @@ -298,18 +283,9 @@ jobs: uses: actions/download-artifact@v3 with: {name: dist, path: dist} - name: Verify existing artifacts - run: - ls -lFhp assets/; - ls -lFhp dist/ + run: ls -lFhp assets/ dist/ # Github - - name: Restore vars.sh - if: contains(github.ref, 'tags/v') - uses: actions/download-artifact@v3 - with: {name: vars.sh, path: ./} - - name: Save vars for following steps - if: contains(github.ref, 'tags/v') - id: vars - run:: bash('release-save-vars') + - :: version-get-vars - name: Move Python packages to assets folder if: contains(github.ref, 'tags/v') run: mv -fv dist/*src.zip assets/. @@ -321,8 +297,8 @@ jobs: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} with: tag_name: ${{github.ref}} - release_name: Release ${{steps.vars.outputs.VERSION}} - body_path: ${{steps.vars.outputs.VERSION_BODY}} + release_name: Release ${{steps.vars.outputs.SRC_VERSION}} + body_path: ${{steps.vars.outputs.SRC_VERSION_BODY}} draft: true prerelease: ${{contains(github.ref, 'rc')}} - name: Upload assets to Github Release diff --git a/.github/workflows/samples.yml b/.github/workflows/samples.yml index b5787f054..9db79466d 100644 --- a/.github/workflows/samples.yml +++ b/.github/workflows/samples.yml @@ -51,9 +51,8 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} CMANY: 'ON' - RYMLSHA: ${{github.event.pull_request.head.sha}} steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive @@ -79,4 +78,14 @@ jobs: - name: custom_c4core run: cd samples/custom_c4core && ./run.sh $BT - name: fetch_content - run: cd samples/fetch_content && ./run.sh $BT $RYMLSHA + run: | + # run this sample only if the branch exists on the repo + set -xe + cd samples/fetch_content + repo=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # https://stackoverflow.com/questions/58033366 + branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} + echo branch=$branch + if [ ! -z "$(git ls-remote $repo | grep $branch)" ] ; then + ./run.sh $BT $branch "$repo" + fi diff --git a/.github/workflows/samples.ys b/.github/workflows/samples.ys index 6a2fa7fc8..89b44c7ad 100644 --- a/.github/workflows/samples.ys +++ b/.github/workflows/samples.ys @@ -20,7 +20,6 @@ jobs: env: !:merge* - ! load('share/env.yaml') - CMANY: ON - RYMLSHA: ${{github.event.pull_request.head.sha}} steps: - :: checkout-action - name: python3 @@ -43,4 +42,14 @@ jobs: - name: custom_c4core run: cd samples/custom_c4core && ./run.sh $BT - name: fetch_content - run: cd samples/fetch_content && ./run.sh $BT $RYMLSHA + run: | + # run this sample only if the branch exists on the repo + set -xe + cd samples/fetch_content + repo=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # https://stackoverflow.com/questions/58033366 + branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} + echo branch=$branch + if [ ! -z "$(git ls-remote $repo | grep $branch)" ] ; then + ./run.sh $BT $branch "$repo" + fi diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 808329645..236240edd 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -90,7 +90,7 @@ jobs: LINT: ${{matrix.lint}} OS: ${{matrix.os}} steps: - - name: checkout + - name: checkout (action) uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/ys/common.ys b/.github/workflows/ys/common.ys index 23f560e8d..31ca8bc43 100644 --- a/.github/workflows/ys/common.ys +++ b/.github/workflows/ys/common.ys @@ -48,7 +48,7 @@ defn runs-on-docker-c4core(which):: #---------------------------------------------------------- checkout-action =:: -- name: checkout +- name: checkout (action) uses: actions/checkout@v4 # use fetch-depth to ensure all tags are fetched with: {submodules: recursive, fetch-depth: 0} @@ -56,7 +56,7 @@ checkout-action =:: #---------------------------------------------------------- checkout-action-docker =:: -- name: checkout +- name: checkout (action + docker) uses: actions/checkout@v4 # use fetch-depth to ensure all tags are fetched with: {submodules: recursive, fetch-depth: 0} @@ -66,25 +66,134 @@ checkout-action-docker =:: #---------------------------------------------------------- + checkout-manual =:: -# This provides a manual checkout because the nodejs version -# prevents use of checkout@v3 or v4 action on ubuntu18.04. -- name: checkout +# This provides a manual checkout, needed because the nodejs version +# prevents use of checkout@v3/v4 action on ubuntu18.04 +- name: checkout (manually) run: | - set -xe - env + set -xeo pipefail + env | sort echo GITHUB_SERVER_URL=$GITHUB_SERVER_URL echo GITHUB_REPOSITORY=$GITHUB_REPOSITORY echo GITHUB_REF=$GITHUB_REF + echo GITHUB_REF_NAME=$GITHUB_REF_NAME echo GITHUB_HEAD_REF=$GITHUB_HEAD_REF - branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} # https://stackoverflow.com/questions/58033366 + repo=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # check the branch + # https://stackoverflow.com/questions/58033366 + branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} echo branch=$branch + # does the branch exist in the repo? + if [ -z "$(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + # refs/pull/485/merge -> pull/485/head + branch=`echo ${GITHUB_REF#refs/} | sed -e 's:merge:head:g'` + echo "... falling back to $branch" + # does the fallback exist? + if [ -z "(git ls-remote $repo | grep $branch)" ] ; then + echo "branch $branch does not exist on $repo" + exit 1 + else + echo "branch $branch exists on $repo" + localbranch=$(echo $branch | sed -e 's@[/:]@_@g') + branch=$branch:$localbranch + echo "naming locally as $branch" + fi + fi + # finally, create the local repo git init -q . - git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY + # needed for running in the docker image. + # see https://github.com/actions/checkout/issues/1169 + git config --system --add safe.directory '*' + # finally, do it! + git remote add origin $repo git fetch origin $branch git reset --hard FETCH_HEAD git submodule update --init --recursive + # show the log + git log --graph --date=relative --date-order --color=always \ + --pretty='%C(yellow)%h %C(cyan)%cd %Cblue%aN%C(auto)%d %Creset%s' \ + | head -30 \ + || echo -n + # show the last commit + git log --name-status HEAD^..HEAD + + +#---------------------------------------------------------- + +version-env =:: +- name: Env (common) + run: | + source vars.sh + echo "SRC_TAG=$SRC_TAG" >> $GITHUB_ENV + echo "SRC_VERSION=$SRC_VERSION" >> $GITHUB_ENV +- name: Env (from tag) + if: contains(github.ref, 'tags/v') + run: | + echo "SRC_VERSION_BODY=$SRC_VERSION_BODY" >> $GITHUB_ENV +- name: Variables (from commit, no tag) + if: ${{ !contains(github.ref, 'tags/v') }} + run: echo 'nothing to do' + + +version-discover =:: +- name: Variables (from tag) + if: contains(github.ref, 'tags/v') + run: | + set -exo pipefail + # https://github.community/t/how-to-get-just-the-tag-name/16241/11 + SRC_TAG=${GITHUB_REF#refs/tags/} + SRC_VERSION=${GITHUB_REF#refs/tags/v} + SRC_VERSION_BODY=`pwd`/changelog/$SRC_VERSION.md + if [ ! -f $SRC_VERSION_BODY ] ; then + echo "version body file was not found: $SRC_VERSION_BODY" + exit 1 + fi + cat <> vars.sh + export SRC_TAG=$SRC_TAG + export SRC_VERSION=$SRC_VERSION + export SRC_VERSION_BODY=$SRC_VERSION_BODY + EOF +- name: Variables (from commit, no tag) + if: ${{ !contains(github.ref, 'tags/v') }} + run: | + set -exo pipefail + branch_name=${GITHUB_REF#refs/heads/} + # builds triggered from PRs have the branch_name like this: refs/pull/150/merge + # so filter to eg pr0150_merge + branch_name=`echo $branch_name | sed "s:refs/pull/\([0-9]*\)/\(.*\):pr0\1_\2:"` + # sanitize the branch name; eg merge/foo-bar -> merge_foo_bar + branch_name=`echo $branch_name | sed 's:[/.-]:_:g'` + SRC_TAG=$(git describe || git rev-parse --short HEAD) # eg v0.2.0-110-gda837e0 + SRC_VERSION="${branch_name}-${SRC_TAG}" + cat < vars.sh + export SRC_TAG=$SRC_TAG + export SRC_VERSION=$SRC_VERSION + EOF +- name: Save vars.sh + uses: actions/upload-artifact@v3 + with: {name: vars.sh, path: ./vars.sh} +- name: Show vars.sh + run: cat vars.sh +- name: Source vars.sh + run: source vars.sh +- :: version-env +- name: Verify vars.sh + run: env | grep SRC + + +version-get-vars =:: +- name: Download vars.sh + uses: actions/download-artifact@v3 + with: {name: vars.sh, path: ./} +- name: Show vars.sh + run: cat vars.sh +- name: Source vars.sh + run: source vars.sh +- :: version-env +- name: Verify vars.sh + run: env | grep SRC #---------------------------------------------------------- diff --git a/samples/fetch_content/CMakeLists.txt b/samples/fetch_content/CMakeLists.txt index 2e313b26b..8f3499606 100644 --- a/samples/fetch_content/CMakeLists.txt +++ b/samples/fetch_content/CMakeLists.txt @@ -1,20 +1,13 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR) project(ryml-quickstart LANGUAGES CXX) -if(RYML_BRANCH_NAME STREQUAL "") - find_program(GIT git REQUIRED) - execute_process(COMMAND git rev-parse --abbrev-ref HEAD - OUTPUT_VARIABLE RYML_BRANCH_NAME - OUTPUT_STRIP_TRAILING_WHITESPACE) -endif() -if(RYML_BRANCH_NAME STREQUAL HEAD) - set(RYML_BRANCH_NAME master) -endif() +set(RYML_REPO_URL https://github.com/biojppm/rapidyaml CACHE STRING "") +set(RYML_BRANCH_NAME master CACHE STRING "") +message(STATUS "FetchContent from repo: ${RYML_REPO_URL}") message(STATUS "FetchContent from branch: ${RYML_BRANCH_NAME}") - include(FetchContent) FetchContent_Declare(ryml - GIT_REPOSITORY https://github.com/biojppm/rapidyaml.git + GIT_REPOSITORY ${RYML_REPO_URL} GIT_TAG ${RYML_BRANCH_NAME} GIT_SHALLOW FALSE # ensure submodules are checked out ) diff --git a/samples/fetch_content/run.sh b/samples/fetch_content/run.sh index cb1d7a008..306471453 100755 --- a/samples/fetch_content/run.sh +++ b/samples/fetch_content/run.sh @@ -2,11 +2,17 @@ # take the build type from the command line, or default to release cfg=${1:-Release} -# force cmake's FetchContent to choose a specific branch, or default to nothing -branch=${2:-} +# force cmake's FetchContent to choose a specific branch, or use the default +branch=${2:-master} +# force cmake's FetchContent to choose a specific repo, or use the default +repo=${3:-https://github.com/biojppm/rapidyaml} + # make sure to run from where this file is cd $(dirname $0) # configure the sample -cmake -S . -B ./build/$cfg -DCMAKE_BUILD_TYPE=$cfg -DRYML_BRANCH_NAME="$branch" +cmake -S . -B ./build/$cfg \ + -DCMAKE_BUILD_TYPE=$cfg \ + -DRYML_BRANCH_NAME=$branch \ + -DRYML_REPO_URL=$repo # build and run the sample cmake --build ./build/$cfg --config $cfg --target run