-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #836 from gugod/ci-ys-ify
let e2e.yml be generated from e2e.ys
- Loading branch information
Showing
4 changed files
with
194 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
SHELL := bash | ||
|
||
YS_VERSION := 0.1.88 | ||
YS_PREFIX := /tmp/rapidyaml | ||
YS := $(YS_PREFIX)/bin/ys-$(YS_VERSION) | ||
|
||
INPUT_FILES := $(wildcard */*) | ||
SOURCE_FILES := $(wildcard *.ys src/*.ys) | ||
SOURCE_FILES := e2e.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) | ||
@if [ -f "$@" ] ; then chmod a+w $@ ; fi | ||
@echo "# DO NOT EDIT - GENERATED FROM .github/workflows/$<" > $@ | ||
@echo >> $@ | ||
$(YS) -Y $< >> $@ | ||
@chmod a-w $@ | ||
@wc -lm --total=never $< $@ | ||
|
||
|
||
# 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)" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,82 @@ | ||
name: E2E | ||
# DO NOT EDIT - GENERATED FROM .github/workflows/e2e.ys | ||
|
||
on: | ||
workflow_dispatch: | ||
name: E2E | ||
'on': | ||
workflow_dispatch: null | ||
push: | ||
paths: | ||
- perlbrew | ||
|
||
- perlbrew | ||
- .github/workflows/e2e.yml | ||
jobs: | ||
debian: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: debian:latest | ||
steps: | ||
- run: | | ||
apt-get update -y | ||
apt-get install -y zsh perl curl | ||
- uses: actions/checkout@v4 | ||
- run: zsh ./test-e2e/run.zsh | ||
ubuntu: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ubuntu:latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: | | ||
sudo apt-get update | ||
sudo apt-get install zsh | ||
- run: zsh ./test-e2e/run.zsh | ||
|
||
- run: | | ||
apt-get update -y | ||
apt-get install -y zsh perl curl | ||
- uses: actions/checkout@v4 | ||
- run: zsh ./test-e2e/run.zsh | ||
fedora: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: fedora:latest | ||
steps: | ||
- run: sudo dnf install -y zsh perl | ||
- uses: actions/checkout@v4 | ||
- run: zsh ./test-e2e/run.zsh | ||
|
||
macos: | ||
strategy: | ||
matrix: | ||
os: ["macos-latest", "macos-13"] | ||
name: ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: shogo82148/actions-setup-perl@v1.31.3 | ||
with: | ||
perl-version: "5.40" | ||
- uses: actions/checkout@v4 | ||
- run: /bin/zsh ./test-e2e/run.zsh | ||
- run: | | ||
dnf install -y zsh perl | ||
- uses: actions/checkout@v4 | ||
- run: zsh ./test-e2e/run.zsh | ||
almalinux: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: almalinux:latest | ||
steps: | ||
- run: | | ||
dnf install -y zsh perl | ||
- uses: actions/checkout@v4 | ||
- run: zsh ./test-e2e/run.zsh | ||
rockylinux: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: docker.io/rockylinux/rockylinux:latest | ||
steps: | ||
- run: | | ||
dnf install -y zsh perl | ||
- uses: actions/checkout@v4 | ||
- run: zsh ./test-e2e/run.zsh | ||
opensuse: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: opensuse/tumbleweed:latest | ||
steps: | ||
- run: | | ||
zypper install -y zsh perl | ||
- uses: actions/checkout@v4 | ||
- run: zsh ./test-e2e/run.zsh | ||
macos-latest: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: shogo82148/actions-setup-perl@v1.31.3 | ||
with: | ||
perl-version: '5.40' | ||
- uses: actions/checkout@v4 | ||
- run: zsh ./test-e2e/run.zsh | ||
macos-13: | ||
runs-on: macos-13 | ||
steps: | ||
- uses: shogo82148/actions-setup-perl@v1.31.3 | ||
with: | ||
perl-version: '5.40' | ||
- uses: actions/checkout@v4 | ||
- run: zsh ./test-e2e/run.zsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- !yamlscript/v0 | ||
|
||
e2e-steps =:: | ||
- uses: actions/checkout@v4 | ||
- run: zsh ./test-e2e/run.zsh | ||
|
||
defn gen-container-job(init image=nil):: | ||
runs-on: ubuntu-latest | ||
container: | ||
image:: image | ||
steps: | ||
- run:: init | ||
- :: e2e-steps | ||
|
||
defn gen-macos-job(os):: | ||
runs-on:: os | ||
steps: | ||
- uses: shogo82148/actions-setup-perl@v1.31.3 | ||
with: | ||
perl-version: "5.40" | ||
- :: e2e-steps | ||
|
||
--- !yamlscript/v0: | ||
name: E2E | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- perlbrew | ||
- .github/workflows/e2e.yml | ||
|
||
jobs: | ||
init =: load("src/init.yaml") | ||
debian:: gen-container-job(init.ubuntu, 'debian:latest') | ||
ubuntu:: gen-container-job(init.ubuntu, 'ubuntu:latest') | ||
fedora:: gen-container-job(init.fedora 'fedora:latest') | ||
almalinux:: gen-container-job(init.almalinux 'almalinux:latest') | ||
rockylinux:: gen-container-job(init.rockylinux 'docker.io/rockylinux/rockylinux:latest') | ||
opensuse:: gen-container-job(init.opensuse 'opensuse/tumbleweed:latest') | ||
macos-latest:: gen-macos-job("macos-latest") | ||
macos-13:: gen-macos-job("macos-13") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
with-dnf: &with-dnf | | ||
dnf install -y zsh perl | ||
|
||
with-apt: &with-apt | | ||
apt-get update -y | ||
apt-get install -y zsh perl curl | ||
|
||
fedora: *with-dnf | ||
almalinux: *with-dnf | ||
rockylinux: *with-dnf | ||
|
||
debian: *with-apt | ||
ubuntu: *with-apt | ||
|
||
opensuse: | | ||
zypper install -y zsh perl | ||
alpine: | | ||
apk add zsh perl |