Skip to content

Commit 6b5fc30

Browse files
authored
Test adding components with the CLI (#143)
* restore all components test * check adding individual components * fix checking individual components * Rename workflow * fix dependencies
1 parent 8c0487d commit 6b5fc30

File tree

2 files changed

+109
-59
lines changed

2 files changed

+109
-59
lines changed
Lines changed: 108 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,112 @@
1-
# name: Add All Components
1+
name: Add Components
22

3-
# on:
4-
# push:
5-
# branches:
6-
# - main
7-
# paths:
8-
# - /**
9-
# - preview/**/*.rs
10-
# - preview/**/Cargo.toml
11-
# - primitives/**/*.rs
12-
# - primitives/**/Cargo.toml
13-
# - .github/**
14-
# - Cargo.toml
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- /**
9+
- preview/**/*.rs
10+
- preview/**/Cargo.toml
11+
- primitives/**/*.rs
12+
- primitives/**/Cargo.toml
13+
- .github/**
14+
- Cargo.toml
1515

16-
# pull_request:
17-
# types: [opened, synchronize, reopened, ready_for_review]
18-
# branches:
19-
# - main
20-
# paths:
21-
# - /**
22-
# - preview/**/*.rs
23-
# - preview/**/Cargo.toml
24-
# - primitives/**/*.rs
25-
# - primitives/**/Cargo.toml
26-
# - .github/**
27-
# - Cargo.toml
16+
pull_request:
17+
types: [opened, synchronize, reopened, ready_for_review]
18+
branches:
19+
- main
20+
paths:
21+
- /**
22+
- preview/**/*.rs
23+
- preview/**/Cargo.toml
24+
- primitives/**/*.rs
25+
- primitives/**/Cargo.toml
26+
- .github/**
27+
- Cargo.toml
2828

29-
# concurrency:
30-
# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
31-
# cancel-in-progress: true
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
31+
cancel-in-progress: true
3232

33-
# jobs:
34-
# deploy-preview:
35-
# if: github.event.pull_request.draft == false
36-
# name: Add All Components
37-
# runs-on: ubuntu-latest
38-
# env:
39-
# CARGO_INCREMENTAL: 1
40-
# steps:
41-
# - name: Checkout code
42-
# uses: actions/checkout@v4
43-
# with:
44-
# ref: "refs/pull/${{ github.event.pull_request.number }}/merge"
45-
# fetch-depth: 0
46-
# - uses: awalsh128/cache-apt-pkgs-action@latest
47-
# with:
48-
# packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
49-
# version: 1.0
50-
# - name: Install Rust
51-
# uses: dtolnay/rust-toolchain@master
52-
# with:
53-
# toolchain: stable
54-
# targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
55-
# - uses: Swatinem/rust-cache@v2
56-
# with:
57-
# cache-all-crates: "true"
58-
# cache-on-failure: "false"
59-
# - uses: cargo-bins/cargo-binstall@main
60-
# - name: Install CLI
61-
# run: cargo binstall dioxus-cli -y --force --version 0.7.0-rc.3
62-
# - name: Add components and check
63-
# run: cd test-harness && dx components add --all --path .. --force && cargo check --all-features
33+
jobs:
34+
add-all-components:
35+
if: github.event.pull_request.draft == false
36+
name: Add All Components
37+
runs-on: ubuntu-latest
38+
env:
39+
CARGO_INCREMENTAL: 1
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
with:
44+
ref: "refs/pull/${{ github.event.pull_request.number }}/merge"
45+
fetch-depth: 0
46+
- uses: awalsh128/cache-apt-pkgs-action@latest
47+
with:
48+
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
49+
version: 1.0
50+
- name: Install Rust
51+
uses: dtolnay/rust-toolchain@master
52+
with:
53+
toolchain: stable
54+
targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
55+
- uses: Swatinem/rust-cache@v2
56+
with:
57+
cache-all-crates: "true"
58+
cache-on-failure: "false"
59+
- name: Install CLI
60+
run: cargo install dioxus-cli --git https://github.com/DioxusLabs/dioxus
61+
- name: Add components and check
62+
run: cd test-harness && dx components add --all --path .. --force && cargo check --all-features
63+
add-each-component:
64+
if: github.event.pull_request.draft == false
65+
name: Add Each Components
66+
runs-on: ubuntu-latest
67+
env:
68+
CARGO_INCREMENTAL: 1
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
with:
73+
ref: "refs/pull/${{ github.event.pull_request.number }}/merge"
74+
fetch-depth: 0
75+
- uses: awalsh128/cache-apt-pkgs-action@latest
76+
with:
77+
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
78+
version: 1.0
79+
- name: Install Rust
80+
uses: dtolnay/rust-toolchain@master
81+
with:
82+
toolchain: stable
83+
targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
84+
- uses: Swatinem/rust-cache@v2
85+
with:
86+
cache-all-crates: "true"
87+
cache-on-failure: "false"
88+
- name: Install CLI
89+
run: cargo install dioxus-cli --git https://github.com/DioxusLabs/dioxus
90+
- name: Add each component and check
91+
run: |
92+
cd preview/src/components/
93+
for file in *; do
94+
if [ -d "$file" ]; then
95+
echo "Testing component: $file"
96+
else
97+
continue
98+
fi
99+
# Go to test harness
100+
cd ../../../test-harness
101+
# Add dependencies manually; TODO: remove this once dx components supports local dependencies
102+
if [ "$file" = "date_picker" ]; then
103+
dx components add calendar,popover --path ..
104+
fi
105+
# Add the component
106+
dx components add "$file" --path ..
107+
# Make sure it still builds
108+
cargo check --all-features
109+
# Undo changes
110+
dx components remove --all --path ..
111+
cd ../preview/src/components/
112+
done

preview/src/components/date_picker/component.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"git": "https://github.com/DioxusLabs/components"
1010
}
1111
],
12+
"componentDependencies": ["calendar", "popover"],
1213
"globalAssets": ["../../../assets/dx-components-theme.css"]
1314
}

0 commit comments

Comments
 (0)