Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate GHA workflow files from originals #485

Merged
merged 22 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
909fec4
Generate GHA workflow files from originals
ingydotnet Dec 27, 2024
b672a7f
Add Makefile and README.md to .github/workflows-src/
ingydotnet Jan 2, 2025
3e2b8b6
Add standard workflow-setup to start of each yml
ingydotnet Jan 2, 2025
74b7c42
DRY up massive duplication in steps
ingydotnet Jan 2, 2025
e7a2d49
Add local workflow fn to simplify python entries
ingydotnet Jan 2, 2025
752dbde
Include workflow bash scripts from files
ingydotnet Jan 3, 2025
07821ca
Normalize block seq indentation in workflow yaml files
ingydotnet Jan 3, 2025
7151eab
Simplify matrix/include specs in workflows
ingydotnet Jan 3, 2025
1d30cd0
DRY the env sections in workflows
ingydotnet Jan 3, 2025
6971e8c
General refactoring of formatting
ingydotnet Jan 3, 2025
94a619d
Use code to gen include matrices in workflows
ingydotnet Jan 3, 2025
c404b34
Don't quote GHA var expansions in workflows
ingydotnet Jan 3, 2025
fc16220
make generated workflows readonly
biojppm Jan 5, 2025
ce45a4c
rarearchs: try ubuntu22.04
biojppm Jan 5, 2025
22c9920
Small change to workflows-src/gcc.yml
ingydotnet Jan 5, 2025
a26c7c8
Add 'make diff' support with yq to workflow Makefile
ingydotnet Jan 5, 2025
9c1ebfd
Further trimming of the input workflows
biojppm Jan 6, 2025
542e352
Rename workflow src files to `.github/workflows/*.ys`
ingydotnet Jan 6, 2025
d725d6a
Wrap some long workflow lines
ingydotnet Jan 6, 2025
3cf6fcb
prefer plain files instead of dot files
biojppm Jan 8, 2025
1ea0a8c
fix PR checkout problems, fix & reuse gettags, cleanup
biojppm Jan 6, 2025
728065b
Add workflow to check status of ys-generated worklows
biojppm Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
SHELL := bash

YS_VERSION := 0.1.87
YS_PREFIX := /tmp/rapidyaml
YS := $(YS_PREFIX)/bin/ys-$(YS_VERSION)

INPUT_FILES := $(wildcard */*)
SOURCE_FILES := $(wildcard *.ys)
TARGET_FILES := $(SOURCE_FILES:%.ys=%.yml)

export PATH := $(YS_PREFIX)/bin:$(PATH)
export YSPATH := $(shell pwd -P)/ys


build: $(TARGET_FILES)


test: force build
@git diff --exit-code $(TARGET_FILES) && \
echo -e '\nPASS - No normative changes to .github/workflows/*.yml'

DIFF_ORIG_COMMIT ?= HEAD
diff:
@for s in $(SOURCE_FILES); do \
s=$${s##*/}; \
t=$${s%.yml}; \
[[ $$(git show $(DIFF_ORIG_COMMIT):.github/workflows/.$$t \
2>/dev/null) ]] && t=.$$t; \
diff -u --color=auto \
<(yq -P 'sort_keys(..)' \
-o=props <(git show $(DIFF_ORIG_COMMIT):.github/workflows/$$t) | \
grep -Ev '(^$$|^#)' \
) \
<(yq -P 'sort_keys(..)' \
-o=props ../workflows/$$s | \
grep -Ev '(^$$|^#)'\
); \
done

force:
touch *.ys

%.yml: %.ys $(YS) $(INPUT_FILES)
@echo "$@"
if [ -f "$@" ] ; then chmod a+w $@ ; fi
@echo "# DO NOT EDIT - GENERATED FROM .github/workflows/$<" > $@
@echo >> $@
$(YS) -Y $< >> $@
@chmod a-w $@
@echo " `wc -ml $<`"
@echo " `wc -ml $@`"


# Auto install a specific version of ys
install-ys: $(YS)
$(YS):
curl -s https://yamlscript.org/install | \
BIN=1 VERSION=$(YS_VERSION) PREFIX=$(YS_PREFIX) bash

stats:
@echo "ys : $$(wc -l *.ys)"
@echo "yml: $$(wc -l *.yml)"
25 changes: 25 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
`.github/workflows/*.ys`
========================

Use YAMLScript for GHA workflows


## Synopsis

```bash
$ make build
$ make test
$ make diff
```


## Description

Edit the `*.ys` files in this directory and run `make build` to generate the
files used by GitHub Actions (`.*.yml`).

Running `make test` runs `make build` and shows the diff in the of the workflow
`.foo.yml` files.

If you are only refactoring the `*.ys` source files, you should see no diff
when you run this.
7 changes: 7 additions & 0 deletions .github/workflows/bash/benchmarks-install.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
which python
which pip
python --version
pip --version
pip install -v -r ext/c4core/cmake/bm-xp/requirements.txt
python -c 'import munch ; print("ok!") ; exit(0)'
echo $?
11 changes: 11 additions & 0 deletions .github/workflows/bash/benchmarks-run.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set -x
source vars.sh
echo SRC_TAG=$SRC_TAG
echo SRC_VERSION=$SRC_VERSION
desc=$SRC_TAG
for bl in ${{matrix.bitlinks}} ; do
dst=$(echo ryml-benchmark_results/$desc/x86_64/${{matrix.cxx}}-${{matrix.bt}}-c++${{matrix.std}}-$bl | sed 's:++-:xx:g' | sed 's:+:x:g')
mkdir -p $dst
find build -name bm-results
mv -vf build/$bl/bm/bm-results/* $dst/.
done
11 changes: 11 additions & 0 deletions .github/workflows/bash/clang-checkout.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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
10 changes: 10 additions & 0 deletions .github/workflows/bash/install-configure.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mkdir -p $BDIR
mkdir -p $IDIR
cmake -S ${{matrix.sdir}} -B $BDIR \
-DRYML_BUILD_TESTS=ON \
-DRYML_VALGRIND=OFF \
-DCMAKE_BUILD_TYPE=${{matrix.bt}} \
-DCMAKE_INSTALL_PREFIX=$IDIR \
${{matrix.gen}} \
${{matrix.vars}} \
${{matrix.commonvars}}
6 changes: 6 additions & 0 deletions .github/workflows/bash/install-preinstall.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if [ "${{matrix.sdir}}" == "test/test_install" ] ; then
mkdir -p $BDIR-staging
cmake -S . -B $BDIR-staging -DCMAKE_INSTALL_PREFIX=$PDIR -DCMAKE_BUILD_TYPE=${{matrix.bt}} ${{matrix.gen}} ${{matrix.commonvars}}
cmake --build $BDIR-staging --config ${{matrix.bt}} --target ${{matrix.tgt}} -j
cmake --build $BDIR-staging --config ${{matrix.bt}} --target install
fi
23 changes: 23 additions & 0 deletions .github/workflows/bash/rarearchs-test-install.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set -x
start_time=$SECONDS
time apt-get update -y
time apt-get install -y \
git \
build-essential
# arm platforms need an up-to-date cmake:
# https://gitlab.kitware.com/cmake/cmake/-/issues/20568
if [ "${{matrix.arch}}" == "armv6" ] || [ "${{matrix.arch}}" == "armv7" ] ; then
time apt-get install -y \
gpg \
wget \
apt-transport-https
wget --no-check-certificate -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null
time apt-get update -y
rm /usr/share/keyrings/kitware-archive-keyring.gpg
time apt-get install kitware-archive-keyring
time apt-get update -y
fi
time apt-get install -y cmake cmake-data
cmake --version
echo "install took $((SECONDS - start_time))"
26 changes: 26 additions & 0 deletions .github/workflows/bash/rarearchs-test-run.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set -x
start_time=$SECONDS
uname -a
pwd
ls -lFhp .
#
bdir=build_${{matrix.arch}}_${{matrix.bt}}_${{matrix.std}}
idir=install_${{matrix.arch}}_${{matrix.bt}}_${{matrix.std}}
mkdir -p $bdir
#
time cmake -S . -B $bdir \
-DCMAKE_INSTALL_PREFIX=$idir \
-DCMAKE_BUILD_TYPE=${{matrix.bt}} \
-DC4_CXX_STANDARD=${{matrix.std}} \
-DCXX_STANDARD=${{matrix.std}} \
-DRYML_DEV=ON \
-DRYML_TEST_SUITE=ON \
-DRYML_BUILD_BENCHMARKS=OFF \
-DRYML_SANITIZE=OFF \
-DRYML_LINT=OFF \
-DRYML_VALGRIND=OFF
#
time cmake --build $bdir -j 3 --target ryml-test-build
#
time cmake --build $bdir -j 3 --target ryml-test-run
echo "run took $((SECONDS - start_time))"
12 changes: 12 additions & 0 deletions .github/workflows/bash/release-create-source-packages.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pwd
ls -lFhp
source vars.sh
echo SRC_TAG=$SRC_TAG
echo SRC_VERSION=$SRC_VERSION
id=${PROJ_PKG_NAME}${SRC_VERSION}
name=${id}-src
mkdir -p assets
git-archive-all --prefix $name assets/$name.tgz
git-archive-all --prefix $name assets/$name.zip
python --version
python tools/amalgamate.py assets/$id.hpp
4 changes: 4 additions & 0 deletions .github/workflows/bash/release-normalize.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sdist_orig=`find dist -type f -name 'rapidyaml-*.zip'`
[ ! -f $sdist_orig ] && exit 1
sdist=`echo $sdist_orig | sed 's:\.zip:-python_src.zip:'`
mv -fv $sdist_orig $sdist
3 changes: 3 additions & 0 deletions .github/workflows/bash/release-package-python.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python --version
pip install -v -r requirements.txt
python setup.py sdist --formats=zip
7 changes: 7 additions & 0 deletions .github/workflows/bash/release-shared-normalize.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set -x
source vars.sh
mkdir -p assets
asset_src=`ls -1 ./build/shared64/*-${{matrix.config.sfxg}}`
asset_dst=./assets/${PROJ_PKG_NAME}${SRC_VERSION}-${{matrix.config.sfxp}}
[ ! -f $asset_src ] && exit 1
cp -fav $asset_src $asset_dst
20 changes: 20 additions & 0 deletions .github/workflows/bash/release-test-with-python.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set -x
echo "python ${{matrix.config.pythonv}} ${{matrix.config.py_arch}} ${{matrix.config.cibw_arch}}"
# skip 32 bit tests, as Python 32 bits are not available in ubuntu
arch="${{matrix.config.cibw_arch}}"
if [ "$arch" == "x86" ] || [ "$arch" == "i686" ] ; then
exit 0
fi
python --version
python -c 'import sys ; import struct ; print("python:", sys.version, struct.calcsize("P") * 8, "bits")'
pip --version
pip install -v -r requirements.txt
pip install -v -r api/python/requirements.txt
for whl in dist/* ; do
pip install -v $whl
pip show -f rapidyaml
python -c 'import ryml ; print("ryml", ryml.version, ryml.version_tuple)'
python -c 'import ryml ; tree = ryml.parse_in_arena(b"{foo: bar}") ; assert tree.key(1) == b"foo" ; assert tree.val(1) == b"bar" ; print(str(tree.key(1), "utf8")) ; print(str(tree.val(1), "utf8"))'
python -m pytest -vvv api/python/tests
pip uninstall -y -v rapidyaml
done
Loading