Skip to content

Commit

Permalink
fix: improve CI workflow (leptos-rs#2838)
Browse files Browse the repository at this point in the history
* fix: improve CI workflow

* fix: add missing `Makefile.toml` to workspace crates
(reactive_stores and reactive_stores_macro)

* fix: remove trailing slash in workflow names

* fix: add gtk example and improve excluding example's logic

* fix: install gtk example deps
  • Loading branch information
sabify authored Sep 20, 2024
1 parent 99403d0 commit 3317002
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 115 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci-changed-examples.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
name: CI Changed Examples

on:
push:
branches:
- main
- leptos_0.6
pull_request:
branches:
- main

- leptos_0.6
jobs:
get-example-changed:
uses: ./.github/workflows/get-example-changed.yml

get-matrix:
needs: [get-example-changed]
uses: ./.github/workflows/get-changed-examples-matrix.yml
with:
example_changed: ${{ fromJSON(needs.get-example-changed.outputs.example_changed) }}

test:
name: CI
needs: [get-example-changed, get-matrix]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-examples.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: CI Examples

on:
push:
branches:
- main
- leptos_0.6
pull_request:
branches:
- main

- leptos_0.6
jobs:
get-leptos-changed:
uses: ./.github/workflows/get-leptos-changed.yml
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/ci-semver.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
name: CI semver

on:
push:
branches:
- main
- leptos_0.6
pull_request:
branches:
- main

- leptos_0.6
jobs:
get-leptos-changed:
uses: ./.github/workflows/get-leptos-changed.yml

test:
needs: [get-leptos-changed]
if: github.event.pull_request.labels[0].name == 'semver' # needs.get-leptos-changed.outputs.leptos_changed == 'true' && github.event.pull_request.labels[0].name != 'breaking'
name: Run semver check (nightly-2024-08-01)
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Semver Checks
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
Expand Down
39 changes: 7 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,25 @@
name: CI

on:
push:
branches:
- main
- leptos_0.6
pull_request:
branches:
- main

- leptos_0.6
jobs:
get-leptos-changed:
uses: ./.github/workflows/get-leptos-changed.yml

get-leptos-matrix:
uses: ./.github/workflows/get-leptos-matrix.yml
test:
name: CI
needs: [get-leptos-changed]
needs: [get-leptos-changed, get-leptos-matrix]
if: needs.get-leptos-changed.outputs.leptos_changed == 'true'
strategy:
matrix:
directory:
[
any_error,
any_spawner,
const_str_slice_concat,
either_of,
hydration_context,
integrations/actix,
integrations/axum,
integrations/utils,
leptos,
leptos_config,
leptos_dom,
leptos_hot_reload,
leptos_macro,
leptos_server,
meta,
next_tuple,
oco,
or_poisoned,
reactive_graph,
router,
router_macro,
server_fn,
server_fn/server_fn_macro_default,
server_fn_macro,
]
matrix: ${{ fromJSON(needs.get-leptos-matrix.outputs.matrix) }}
fail-fast: false
uses: ./.github/workflows/run-cargo-make-task.yml
with:
directory: ${{ matrix.directory }}
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/get-example-changed.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: Examples Changed Call

on:
workflow_call:
outputs:
example_changed:
description: "Example Changed"
value: ${{ jobs.get-example-changed.outputs.example_changed }}

jobs:
get-example-changed:
name: Get Example Changed
Expand All @@ -18,21 +16,17 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get example files that changed
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: |
examples/**
!examples/cargo-make/**
!examples/gtk/**
!examples/Makefile.toml
!examples/*.md
- name: List example files that changed
run: echo '${{ steps.changed-files.outputs.all_changed_files }}'

- name: Set example_changed
id: set-example-changed
run: |
Expand Down
18 changes: 7 additions & 11 deletions .github/workflows/get-examples-matrix.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
name: Get Examples Matrix Call

on:
workflow_call:
outputs:
matrix:
description: "Matrix"
value: ${{ jobs.create.outputs.matrix }}

jobs:
create:
name: Create Examples Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
env:
# separate examples using "|" (vertical bar) char like "a|b|c".
# cargo-make should be excluded by default.
EXCLUDED_EXAMPLES: cargo-make
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install jq
run: sudo apt-get install jq

- name: Set Matrix
id: set-matrix
run: |
examples=$(ls examples |
awk '{print "examples/" $0}' |
grep -v .md |
grep -v examples/Makefile.toml |
grep -v examples/cargo-make |
grep -v examples/gtk |
examples=$(ls -1d examples/*/ |
grep -vE "($EXCLUDED_EXAMPLES)" |
sed 's/\/$//' |
jq -R -s -c 'split("\n")[:-1]')
echo "Example Directories: $examples"
echo "matrix={\"directory\":$examples}" >> "$GITHUB_OUTPUT"
- name: Print Location Info
run: |
echo "Workspace: ${{ github.workspace }}"
Expand Down
40 changes: 7 additions & 33 deletions .github/workflows/get-leptos-changed.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: Get Leptos Changed Call

on:
workflow_call:
outputs:
leptos_changed:
description: "Leptos Changed"
value: ${{ jobs.create.outputs.leptos_changed }}

jobs:
create:
name: Detect Source Change
Expand All @@ -18,43 +16,19 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get source files that changed
id: changed-source
uses: tj-actions/changed-files@v45
with:
files: |
any_error/**
any_spawner/**
const_str_slice_concat/**
either_of/**
hydration_context/**
integrations/actix/**
integrations/axum/**
integrations/utils/**
leptos/**
leptos_config/**
leptos_dom/**
leptos_hot_reload/**
leptos_macro/**
leptos_server/**
meta/**
next_tuple/**
oco/**
or_poisoned/**
reactive_graph/**
reactive_stores/**
reactive_stores_macro/**
router/**
router_macro/**
server_fn/**
server_fn/server_fn_macro_default/**
server_fn_macro/**
tachys/**
files_ignore: |
.*/**/*
cargo-make/**/*
examples/**/*
projects/**/*
benchmarks/**/*
docs/**/*
- name: List source files that changed
run: echo '${{ steps.changed-source.outputs.all_changed_files }}'

- name: Set leptos_changed
id: set-source-changed
run: |
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/get-leptos-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Get Leptos Matrix Call
on:
workflow_call:
outputs:
matrix:
description: "Matrix"
value: ${{ jobs.create.outputs.matrix }}
jobs:
create:
name: Create Leptos Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get install jq
- name: Set Matrix
id: set-matrix
run: |
crates=$(cargo metadata --no-deps --quiet --format-version 1 |
jq -r '.packages[] | select(.name != "workspace") | .manifest_path| rtrimstr("/Cargo.toml")' |
sed "s|$(pwd)/||" |
jq -R -s -c 'split("\n")[:-1]')
echo "Leptos Directories: $crates"
echo "matrix={\"directory\":$crates}" >> "$GITHUB_OUTPUT"
- name: Print Location Info
run: |
echo "Workspace: ${{ github.workspace }}"
pwd
ls | sort -u
Loading

0 comments on commit 3317002

Please sign in to comment.