Skip to content

tests: rewrite fullsort tests, again #309

tests: rewrite fullsort tests, again

tests: rewrite fullsort tests, again #309

name: Build and Test
on:
- push
env:
CCACHE_VERSION: 4.8
BUILD_TYPE: Release
jobs:
build-and-test:
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Windows-MSVC",
os: windows-latest,
cc: "cl",
cxx: "cl",
}
- {
name: "Ubuntu-GCC",
os: ubuntu-latest,
cc: "gcc",
cxx: "g++"
}
- {
name: "Ubuntu-Clang",
os: ubuntu-latest,
cc: "clang",
cxx: "clang++"
}
- {
name: "macOS-Clang",
os: macos-latest,
cc: "clang",
cxx: "clang++"
}
steps:
- name: Checkout
uses: actions/checkout@v3.5.2
- name: Setup VS env
uses: egor-tensin/vs-shell@v2
if: startsWith(runner.os, 'Windows')
with:
arch: x64
- name: Setup Ninja
uses: ashutoshvarma/setup-ninja@master
with:
version: 1.11.1
- name: Check for AVX2/512
shell: bash
id: check_cpu
continue-on-error: true
run: |
runner_os=${{ runner.os }}
set +e
case ${runner_os} in
macOS)
sysctl hw.model
sysctl kern.version
sysctl machdep.cpu.leaf7_features > leaf7_features.txt
cat leaf_features.txt
grep -q -E '\s+AVX2\s+' leaf7_features.txt
[[ $? == 0 ]] && has_avx2=1 || has_avx2=0
grep -q -E '\s+AVX512\s+' leaf7_features.txt
[[ $? == 0 ]] && has_avx512=1 || has_avx512=0
;;
Linux)
lscpu
grep -q -E '^flags\s*:.*\bavx2\b' /proc/cpuinfo
[[ $? == 0 ]] && has_avx2=1 || has_avx2=0
grep -q -E '^flags\s*:.*\bavx512f\b' /proc/cpuinfo
[[ $? == 0 ]] && has_avx512=1 || has_avx512=0
;;
Windows)
aria2c "https://download.sysinternals.com/files/Coreinfo.zip" -o CoreInfo.zip
unzip CoreInfo.zip
rm CoreInfo.zip
./CoreInfo64.exe -accepteula -f | iconv -t utf-8 > coreinfo.txt
cat coreinfo.txt
grep -q -E '^AVX2\s+\*' coreinfo.txt
[[ $? == 0 ]] && has_avx2=1 || has_avx2=0
grep -q -E '^AVX-512-F\s+\*' coreinfo.txt
[[ $? == 0 ]] && has_avx512=1 || has_avx512=0
;;
esac
echo "has_avx2=${has_avx2}" >> $GITHUB_OUTPUT
echo "has_avx512=${has_avx512}" >> $GITHUB_OUTPUT
#- name: show cpu support
# run: |
# echo avx2=${{ steps.check_cpu.outputs.has_avx2 }}
# echo avx512=${{ steps.check_cpu.outputs.has_avx512 }}
- name: Download ccache
id: ccache
shell: bash
run: |
runner_os=${{ runner.os }}
case ${runner_os} in
macOS)
aria2c https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-darwin.tar.gz -o ccache.tar.gz
tar xf ccache.tar.gz --strip-components=1 ccache-${CCACHE_VERSION}-darwin/ccache
rm ccache.tar.gz
;;
Linux)
aria2c https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz -o ccache.tar.xz
tar xf ccache.tar.xz --strip-components=1 ccache-${CCACHE_VERSION}-linux-x86_64/ccache
rm ccache.tar.xz
;;
Windows)
aria2c https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-windows-x86_64.zip -o ccache.zip
unzip -j ccache.zip ccache-${CCACHE_VERSION}-windows-x86_64/ccache.exe
rm ccache.zip
;;
esac
- name: Prepare ccache timestamp
id: ccache_timestamp
shell: bash
run: |
echo "timestamp=$(date -u '+%Y-%m-%d-%H;%M;%S')" > $GITHUB_OUTPUT
- name: ccache cache files
uses: actions/cache@v3.3.1
with:
path: |
.ccache
.cpm
key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_timestamp.outputs.timestamp }}
restore-keys: |
${{ matrix.config.name }}-ccache-
- name: Configure
shell: bash
run: |
export CC=${{ matrix.config.cc }} CXX=${{ matrix.config.cxx }}
export PATH="${GITHUB_WORKSPACE}:$PATH"
export CPM_SOURCE_CACHE="${GITHUB_WORKSPACE}/.cpm"
cmake -S . -B build -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DVXSORT_CCACHE=ON -G Ninja
- name: Build
shell: bash
run: |
export NINJA_STATUS="[%f/%t %o/sec]"
export PATH="${GITHUB_WORKSPACE}:$PATH"
export CCACHE_BASEDIR="${GITHUB_WORKSPACE}" CCACHE_DIR="${GITHUB_WORKSPACE}/.ccache" CCACHE_COMPRESS="true" CCACHE_COMPRESSLEVEL="6" CCACHE_MAXSIZE="600M" CCACHE_COMPILERCHECK="content"
export CPM_SOURCE_CACHE="${GITHUB_WORKSPACE}/.cpm"
ccache -p
ccache -z
cmake --build build
ccache -s
- name: Upload .ccache to cache
uses: actions/cache/save@v3
if: always()
with:
path: |
.ccache
.cpm
key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_timestamp.outputs.timestamp }}
- name: Run tests
shell: bash
working-directory: build
if: steps.check_cpu.outputs.has_avx2 == 1 || steps.check_cpu.outputs.has_avx512 == 1
run: |
export GTEST_OUTPUT="xml:junit/"
set +e
ctest -J $(nproc)
rc=$?
echo ctest returned $?
if [[ $? != 0 ]]; then
echo Error log:
echo ==========
cat ./Testing/Temporary/LastTest.log
fi
- name: Test Report
uses: dorny/test-reporter@v1
if: steps.check_cpu.outputs.has_avx2 == 1 || steps.check_cpu.outputs.has_avx512 == 1
with:
name: tests/${{ matrix.config.name}}
path: build/tests/junit/*.xml
reporter: java-junit
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: tests-${{ matrix.config.name}}
path: build/tests/junit/*.xml
publish-test-results:
name: "Publish Tests Results"
needs: build-and-test
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
contents: read
issues: read
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
id: test
with:
files: "artifacts/**/*.xml"
- name: Set badge properties
id: badgeprops
shell: bash
run: |
conclusion="${{ fromJSON( steps.test.outputs.json ).conclusion }}"
num_suites="${{ fromJSON( steps.test.outputs.json ).stats.suites }}"
num_tests="${{ fromJSON( steps.test.outputs.json ).stats.tests }}"
num_runs="${{ fromJSON( steps.test.outputs.json ).stats.runs }}"
num_tests_skip="${{ fromJSON( steps.test.outputs.json ).stats.tests_skip }}"
num_runs_skip="${{ fromJSON( steps.test.outputs.json ).stats.runs_skip }}"
runs_error="${{ fromJSON( steps.test.outputs.json ).stats.runs_error }}"
runs_fail="${{ fromJSON( steps.test.outputs.json ).stats.runs_fail }}"
tests_fail="${{ fromJSON( steps.test.outputs.json ).stats.tests_fail }}"
tests_error="${{ fromJSON( steps.test.outputs.json ).stats.tests_error }}"
case "${conclusion}" in
success)
color="31c653"
conclusion_suite_text="${conclusion}"
conclusion_test_text="${conclusion}"
conclusion_run_text="${conclusion}"
;;
failure)
color="800000"
conclusion_suite_text="${conclusion}"
conclusion_test_text="${conclusion} (${tests_error})"
conclusion_run_text="${conclusion} (${runs_error})"
;;
neutral)
color="696969"
conclusion_suite_text="${conclusion}"
conclusion_test_text="${conclusion}"
conclusion_run_text="${conclusion}"
;;
esac
cat << EOF >> $GITHUB_OUTPUT
color=${color}
suites_badge_text=${num_suites}: ${conclusion_suite_text}
tests_badge_text=$(printf "%'d" ${num_tests}) ($(printf "%'d" ${num_tests_skip}) skipped): ${conclusion_test_text}
runs_badge_text=$(printf "%'d" ${num_runs}) ($(printf "%'d" ${num_runs_skip}) skipped): ${conclusion_run_text}
EOF
- name: Create suites badge
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
with:
label: Suites
status: '${{ steps.badgeprops.outputs.suites_badge_text }}'
color: ${{ steps.badgeprops.outputs.color }}
path: vxsort-suites-badge.svg
- name: Create tests badge
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
with:
label: Tests
status: '${{ steps.badgeprops.outputs.tests_badge_text }}'
color: ${{ steps.badgeprops.outputs.color }}
path: vxsort-tests-badge.svg
- name: Create runs badge
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
with:
label: Executions
status: '${{ steps.badgeprops.outputs.runs_badge_text }}'
color: ${{ steps.badgeprops.outputs.color }}
path: vxsort-runs-badge.svg
- name: Upload suites badge to Gist
# Upload only for master branch
if: >
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' ||
github.event_name != 'workflow_run' && github.ref == 'refs/heads/master'
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
with:
token: ${{ secrets.GIST_TOKEN }}
gistURL: https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321
file: vxsort-suites-badge.svg
- name: Upload tests badge to Gist
# Upload only for master branch
if: >
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' ||
github.event_name != 'workflow_run' && github.ref == 'refs/heads/master'
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
with:
token: ${{ secrets.GIST_TOKEN }}
gistURL: https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321
file: vxsort-tests-badge.svg
- name: Upload runs badge to Gist
# Upload only for master branch
if: >
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' ||
github.event_name != 'workflow_run' && github.ref == 'refs/heads/master'
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
with:
token: ${{ secrets.GIST_TOKEN }}
gistURL: https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321
file: vxsort-runs-badge.svg