Skip to content

Commit

Permalink
fix checkout problems
Browse files Browse the repository at this point in the history
  • Loading branch information
biojppm committed Jan 7, 2025
1 parent d725d6a commit fb0b0b2
Show file tree
Hide file tree
Showing 28 changed files with 625 additions and 311 deletions.
94 changes: 73 additions & 21 deletions .github/workflows/.benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,69 @@ jobs:
gettag:
runs-on: ubuntu-latest
steps:
- name: checkout
- name: checkout (action)
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Variables (from tag)
if: contains(github.ref, 'tags/v')
run: |
#!/bin/bash
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 <<EOF > 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 <<EOF >> 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
#!/bin/bash
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 <<EOF > 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
Expand Down Expand Up @@ -115,18 +139,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
Expand All @@ -142,38 +184,48 @@ 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: |
exposrt NUM_JOBS_BUILD=1
export CMAKE_FLAGS="-DPython_EXECUTABLE=$(which python)"
echo "NUM_JOBS_BUILD=$NUM_JOBS_BUILD" >> $GITHUB_ENV
echo "CMAKE_FLAGS=\"$CMAKE_FLAGS\"" >> $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
Expand Down
52 changes: 42 additions & 10 deletions .github/workflows/.clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/.clang_tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/.coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}}
Expand All @@ -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
Expand All @@ -79,9 +82,9 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: coverage-static64
path: |
build/static64/lcov/
build/static64/coverage3-final_filtered.lcov
path:
- build/static64/lcov
- build/static64/coverage3-final_filtered.lcov
- name: static64-submit-codecov
run: source .github/setenv.sh && c4_submit_coverage static64 codecov
- name: static32-configure-------------------------------------------------
Expand All @@ -94,8 +97,8 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: coverage-static32-cxx${{matrix.std}}
path: |
build/static32/lcov
build/static32/coverage3-final_filtered.lcov
path:
- build/static32/lcov
- build/static32/coverage3-final_filtered.lcov
- name: static32-submit-codecov
run: source .github/setenv.sh && c4_submit_coverage static32 codecov
Loading

0 comments on commit fb0b0b2

Please sign in to comment.