Skip to content

Commit

Permalink
Rename workflow src files to .github/workflows/*.ys
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Jan 6, 2025
1 parent 9c1ebfd commit 542e352
Show file tree
Hide file tree
Showing 50 changed files with 54 additions and 48 deletions.
23 changes: 0 additions & 23 deletions .github/workflows-src/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/benchmarks.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/benchmarks.ys

name: benchmarks
defaults:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/clang.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/clang.ys

name: clang
defaults:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/clang_tidy.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/clang_tidy.ys

name: clang_tidy
defaults:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/codeql.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/codeql.ys

name: CodeQL
'on':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/coverage.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/coverage.ys

name: coverage
defaults:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/emscripten.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/emscripten.ys

name: emscripten
defaults:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gcc.yml → .github/workflows/.gcc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/gcc.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/gcc.ys

name: gcc
defaults:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/install.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/install.ys

name: test_install
defaults:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/macosx.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/macosx.ys

name: macosx
defaults:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/rarearchs.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/rarearchs.ys

name: rarearchs
defaults:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/release.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/release.ys

name: release
defaults:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/samples.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/samples.ys

name: samples
defaults:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT - GENERATED FROM .github/workflows-ys/windows.yml
# DO NOT EDIT - GENERATED FROM .github/workflows/windows.ys

name: windows
defaults:
Expand Down
26 changes: 15 additions & 11 deletions .github/workflows-src/Makefile → .github/workflows/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ YS_VERSION := 0.1.87
YS_PREFIX := /tmp/rapidyaml
YS := $(YS_PREFIX)/bin/ys-$(YS_VERSION)

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

export PATH := $(YS_PREFIX)/bin:$(PATH)
export YSPATH := $(shell pwd -P)/ys
Expand All @@ -16,30 +17,33 @@ default:
build: $(TARGET_FILES)

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

DIFF_ORIG_COMMIT ?= HEAD
diff:
@for f in $(SOURCE_FILES); do \
f=$${f##*/}; \
@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/$$f) | \
-o=props <(git show $(DIFF_ORIG_COMMIT):.github/workflows/$$t) | \
grep -Ev '(^$$|^#)' \
) \
<(yq -P 'sort_keys(..)' \
-o=props ../workflows/$$f | \
-o=props ../workflows/$$s | \
grep -Ev '(^$$|^#)'\
); \
done

force:
touch *.yml
touch *.ys

../workflows/%: % $(YS)
.%.yml: %.ys $(YS)
@[ -f $@ ] && chmod a+w $@
@echo "# DO NOT EDIT - GENERATED FROM .github/workflows-ys/$<" > $@
@echo "# DO NOT EDIT - GENERATED FROM .github/workflows/$<" > $@
@echo >> $@
ys -Y $< >> $@
@chmod a-w $@
Expand Down
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#----------------------------------------------------------
defn workflow-setup(name=nil overrides={})::
name =: name || FILE.replace(/.*\//).replace(/\.yml$/)
name =: name || FILE.replace(/.*\//).replace(/\.ys$/)
name:: name
defaults:
run:
Expand Down

0 comments on commit 542e352

Please sign in to comment.