Skip to content

Commit 3773396

Browse files
committed
Pkl based workflows
1 parent 3c05a5d commit 3773396

File tree

9 files changed

+317
-128
lines changed

9 files changed

+317
-128
lines changed

.github/pkl-workflows/ci.pkl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
amends "https://cdn.jsdelivr.net/gh/StefMa/pkl-gha@77880b64db1f3bf24b31a359311a6f7ef64bffaa/Workflow.pkl"
2+
import "https://cdn.jsdelivr.net/gh/StefMa/pkl-gha@77880b64db1f3bf24b31a359311a6f7ef64bffaa/Action.pkl"
3+
4+
import "https://cdn.jsdelivr.net/gh/paradox460/shared-pkl@0c33020a8e18437752765a0483aeefbf3bb03fe5/gha/mise.pkl"
5+
import "https://cdn.jsdelivr.net/gh/paradox460/shared-pkl@0c33020a8e18437752765a0483aeefbf3bb03fe5/gha/elixir.pkl"
6+
7+
name = "CI"
8+
9+
on {
10+
pull_request {
11+
types = new Listing {"opened" "synchronize"}
12+
branches = new Listing { "main" }
13+
}
14+
push {
15+
branches = outer.pull_request.branches
16+
}
17+
merge_group {}
18+
workflow_dispatch {}
19+
}
20+
21+
jobs {
22+
["ci"] = new {
23+
name = "CI"
24+
`runs-on` = "ubuntu-24.04"
25+
env = new EnvironmentVariables {
26+
["MIX_ENV"] = "test"
27+
}
28+
steps {
29+
Action.checkout
30+
(mise.Mise) {
31+
miseToml = """
32+
[settings]
33+
enable_tools = ["elixir", "erlang", "rust"]
34+
"""
35+
}
36+
...elixir.elixir
37+
new {
38+
name = "Run Tests"
39+
run = "mix test --warnings-as-errors"
40+
}
41+
}
42+
}
43+
}

.github/pkl-workflows/release.pkl

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
amends "https://cdn.jsdelivr.net/gh/Paradox460/pkl-gha@9a8ef2e658223fd7cb08a68b5a63a44ec6566166/Workflow.pkl"
2+
import "https://cdn.jsdelivr.net/gh/Paradox460/pkl-gha@9a8ef2e658223fd7cb08a68b5a63a44ec6566166/Action.pkl"
3+
4+
import "https://cdn.jsdelivr.net/gh/paradox460/shared-pkl@0c33020a8e18437752765a0483aeefbf3bb03fe5/gha/mise.pkl"
5+
6+
name = "Build and release NIFs"
7+
8+
on {
9+
push {
10+
tags = new Listing { "v*" }
11+
}
12+
workflow_dispatch {}
13+
}
14+
15+
local job_matrix = new Dynamic {
16+
os = "ubuntu-22.04"
17+
`use-cross`= true
18+
}
19+
20+
jobs {
21+
["build_release"] = new {
22+
name = "NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }})"
23+
`runs-on` = "${{ matrix.job.os }}"
24+
strategy = new {
25+
`fail-fast` = false
26+
matrix = new {
27+
["nif"] = new Listing { "2.15" }
28+
["job"] = new Listing {
29+
(job_matrix) { target = "arm-unknown-linux-gnueabihf" }
30+
(job_matrix) { target = "aarch64-unknown-linux-gnu" }
31+
(job_matrix) { target = "aarch64-unknown-linux-musl" }
32+
(job_matrix) { target = "riscv64gc-unknown-linux-gnu" }
33+
(job_matrix) { target = "x86_64-unknown-linux-musl" }
34+
(job_matrix) {
35+
target = "aarch64-apple-darwin"
36+
os = "macos-13"
37+
`use-cross` = null
38+
}
39+
(job_matrix) {
40+
target = "x86_64-apple-darwin"
41+
os = "macos-13"
42+
`use-cross` = null
43+
}
44+
(job_matrix) {
45+
target = "x86_64-unknown-linux-gnu"
46+
`use-cross` = null
47+
}
48+
(job_matrix) {
49+
target = "x86_64-pc-windows-gnu"
50+
os = "windows-2019"
51+
`use-cross` = null
52+
}
53+
(job_matrix) {
54+
target = "x86_64-pc-windows-msvc"
55+
os = "windows-2019"
56+
`use-cross` = null
57+
}
58+
}
59+
}
60+
}
61+
permissions = new {
62+
contents = "write"
63+
`id-token` = "write"
64+
attestations = "write"
65+
}
66+
steps {
67+
Action.checkout
68+
new {
69+
name = "Extract Project Version"
70+
shell = "bash"
71+
run = #"echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV"#
72+
}
73+
new {
74+
name = "Install rust toolchain"
75+
uses = "dtolnay/rust-toolchain@stable"
76+
with {
77+
["toolchain"] = "stable"
78+
["target"] = "${{ matrix.job.target }}"
79+
}
80+
}
81+
new {
82+
name = "Build"
83+
id = "build-crate"
84+
uses = "philss/rustler-precompiled-action@v1.1.4"
85+
with {
86+
["project-name"] = "djot_nif"
87+
["project-version"] = "${{ env.PROJECT_VERSION }}"
88+
["target"] = "${{ matrix.job.target }}"
89+
["nif-version"] = "${{ matrix.nif }}"
90+
["use-cross"] = "${{ matrix.job.use-cross }}"
91+
["project-dir"] = "native/djot_nif"
92+
}
93+
}
94+
new {
95+
name = "Artifact attestation"
96+
uses = "actions/attest-build-provenance@v1"
97+
with {
98+
["subject-path"] = "${{ steps.build-crate.outputs.file-path }}"
99+
}
100+
}
101+
(Action.uploadArtitact) {
102+
name = "${{ steps.build-crate.outputs.file-name }}"
103+
path = "${{ steps.build-crate.outputs.file-path }}"
104+
}
105+
new {
106+
name = "Publish archives and packages"
107+
uses = "softprops/action-gh-release@v2"
108+
with {
109+
["files"] = "${{ steps.build-crate.outputs.file-path }}"
110+
}
111+
`if` = "startsWith(github.ref, 'refs/tags/')"
112+
}
113+
}
114+
}
115+
}

.github/workflows/ci.yaml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Do not modify!
2+
# This file was generated from a template using https://github.com/StefMa/pkl-gha
3+
4+
name: CI
5+
'on':
6+
merge_group: {}
7+
pull_request:
8+
types:
9+
- opened
10+
- synchronize
11+
branches:
12+
- main
13+
push:
14+
branches:
15+
- main
16+
workflow_dispatch: {}
17+
jobs:
18+
ci:
19+
name: CI
20+
runs-on: ubuntu-24.04
21+
env:
22+
MIX_ENV: test
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: jdx/mise-action@v2
26+
with:
27+
mise_toml: |-
28+
[settings]
29+
enable_tools = ["elixir", "erlang", "rust"]
30+
- name: Elixir Deps cache
31+
id: elixir-deps-cache
32+
uses: actions/cache@v4
33+
with:
34+
path: |-
35+
deps
36+
_build
37+
.mix/archives/
38+
key: elixir-build-${{hashFiles('.mise.lock')}}-${{hashFiles('mix.lock')}}
39+
restore-keys: elixir-build-${{hashFiles('.mise.lock')}}-
40+
- name: Install Elixir Dependencies
41+
run: |-
42+
mix local.hex --force --if-missing
43+
mix deps.get
44+
- name: Run Tests
45+
run: mix test --warnings-as-errors

.github/workflows/release.yaml

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)