chore: setup mask to use the smoke-tests repo (#1583)

This commit is contained in:
Lucas Fernandes Nogueira 2021-04-22 15:33:29 -03:00 committed by GitHub
parent 8fd1baf69b
commit 7506a52844
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 48 deletions

3
.gitignore vendored
View File

@ -5,6 +5,9 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
# smoke-tests repo
/smoke-tests
# Runtime data
pids
*.pid

View File

@ -8,14 +8,14 @@
## prepare
> Setup all stuff needed for running the examples
> Setup all stuff needed for running the smoke tests
```sh
git clone --recursive git@github.com:tauri-apps/examples.git \
|| (cd examples && git pull origin dev; cd ..) # always prepare up-to-date examples in case it's already available
git clone --recursive git@github.com:tauri-apps/smoke-tests.git \
|| (cd smoke-tests && git pull origin dev; cd ..) # always prepare up-to-date smoke tests in case it's already available
cargo build
cargo install cargo-web # used by example rust/yew
cargo build --lib
cargo install cargo-web # used by rust/yew
. .scripts/setup.sh
```
@ -28,24 +28,24 @@ Push-Location $MyInvocation.MyCommand.Path
# send git stderr to powershell stdout
$env:GIT_REDIRECT_STDERR = '2>&1'
# if the examples path doesn't exist.
if (-Not (Test-Path $CWD\examples -PathType Any)) {
# if the smoke-tests path doesn't exist.
if (-Not (Test-Path $CWD\smoke-tests -PathType Any)) {
Start-Job -ScriptBlock {
# Setup Environment to execute in the tauri directory.
$CWD = [Environment]::CurrentDirectory
Push-Location $MyInvocation.MyCommand.Path
[Environment]::CurrentDirectory = $PWD
#clone the examples repo into the examples folder
git clone --recursive https://github.com/tauri-apps/examples.git $CWD\examples
#clone the smoke-tests repo into the smoke-tests folder
git clone --recursive https://github.com/tauri-apps/smoke-tests.git $CWD\smoke-tests
} | Receive-Job -AutoRemoveJob -Wait
}
# Enter the examples folder and pull the latest data from origin/dev
cd examples; git pull origin dev; cd ..
# Enter the smoke-tests folder and pull the latest data from origin/dev
cd smoke-tests; git pull origin dev; cd ..
# build and install everything Rust related.
cargo build
cargo build --lib
cargo install cargo-web
. .scripts/setup.ps1
@ -53,17 +53,17 @@ cargo install cargo-web
## run
![tauri-mask-run-example](https://user-images.githubusercontent.com/4953069/75866011-00ed8600-5e37-11ea-9106-3cb104a05f80.gif)
![tauri-mask-run-smoke-test](https://user-images.githubusercontent.com/4953069/75866011-00ed8600-5e37-11ea-9106-3cb104a05f80.gif)
### run example (example)
### run smoke-test (name)
> Run specific example in dev mode
> Run specific smoketest in dev mode
```sh
shopt -s globstar
cd examples/**/$example 2>/dev/null \
|| cd examples/**/$example/$example # workaround for rust/yew/todomvc/todomvc
cd smoke-tests/**/$name 2>/dev/null \
|| cd smoke-tests/**/$name/$name # workaround for rust/yew/todomvc/todomvc
case "$PWD" in
*/node/*)
@ -71,20 +71,20 @@ case "$PWD" in
;;
*/rust/*)
cargo web deploy
[ $example = `basename $(dirname $PWD)` ] && cd ..
[ $name = `basename $(dirname $PWD)` ] && cd ..
yarn add tauri@link:../../../tooling/cli.js
yarn && yarn tauri dev
;;
*)
echo unknown project $(dirname $example)/$example
echo unknown project $(dirname $name)/$name
;;
esac
```
```powershell
param(
[string] $example_name
[string] $smoke_test_name
)
# Setup Environment to execute in the tauri directory.
@ -93,31 +93,31 @@ Push-Location $MyInvocation.MyCommand.Path
[Environment]::CurrentDirectory = $PWD
# get the example paths.
$example_path = Get-ChildItem examples\*\*\$env:example
$smoke_test_path = Get-ChildItem smoke-tests\*\*\$env:name
# if the example path is null get the todomvc path.
if ($example_path -eq $null) {
$example_path = Get-ChildItem examples\*\*\*\$env:example\$env:example
if ($smoke_test_path -eq $null) {
$smoke_test_path = Get-ChildItem smoke-tests\*\*\*\$env:name\$env:name
}
# if the example path is still null get the helloworld example path.
if ($example_path -eq $null) {
$example_path = Get-ChildItem examples\tauri\*\$env:example
if ($smoke_test_path -eq $null) {
$smoke_test_path = Get-ChildItem smoke-tests\tauri\*\$env:name
}
# switch on the parent folder name.
switch ($example_path.parent) {
switch ($smoke_test_path.parent) {
# if node, run yarn.
{"vanillajs" -Or "react" -Or "svelte" -Or "vue"} {
cd $example_path.FullName; yarn; yarn tauri:dev
cd $smoke_test_path.FullName; yarn; yarn tauri:dev
}
# if rust, run cargo web deploy
"yew" {
cd $example_path.FullName; cargo web deploy
cd $smoke_test_path.FullName; cargo web deploy
}
# if tauri run the helloworld example from the tauri folder.
"tauri" {
cd $CWD/tauri/examples/helloworld/src-tauri; cargo run
cd $CWD/tauri; cargo run --bin helloworld
}
# transpiled are not supported yet.
"transpiled" {
@ -128,12 +128,12 @@ switch ($example_path.parent) {
## list
### list examples
### list smoke tests
> List all available examples
> List all available smoke tests
```sh
find examples/*/*/* -maxdepth 0 -type d -not -path '*.git*' \
find smoke-tests/*/*/* -maxdepth 0 -type d -not -path '*.git*' \
-exec sh -c 'echo $(basename $(dirname {}))/$(basename {})' \;
```
@ -143,32 +143,31 @@ $CWD = [Environment]::CurrentDirectory
Push-Location $MyInvocation.MyCommand.Path
[Environment]::CurrentDirectory = $PWD
# initialize the examples list.
$examples = @()
# initialize the smoke-tests list.
$smoke_tests = @()
# get the helloworld example
$examples += Get-ChildItem examples/*/* -Filter helloworld
# get the rest of the examples.
$examples += Get-ChildItem examples/*/* -Directory -Exclude ('src*', 'public', 'test*', 'source', 'lib', 'web', 'dist', 'node_*')
# get the helloworld smoke tests
$smoke_tests += Get-ChildItem smoke-tests/*/* -Filter helloworld
# get the rest of the smoke-tests.
$smoke_tests += Get-ChildItem smoke-tests/*/* -Directory -Exclude ('src*', 'public', 'test*', 'source', 'lib', 'web', 'dist', 'node_*')
# print out the examples.
foreach($e in $examples) {
# print out the smoke tests.
foreach($e in $smoke_tests) {
Write-Output("$($e.Name): $($e.Parent)/$($e.Name)")
}
```
## clean
> Remove installed dependencies and reset examples in case something gone wrong
> Remove installed dependencies and reset smoke tests in case something gone wrong
```sh
cargo uninstall tauri-bundler
cargo clean
shopt -s globstar
rm -r **/node_modules
cd examples
cd smoke-tests
git checkout -- . # discard all unstaged changes
git clean -dfX # remove all untracked files & directories
```
@ -179,20 +178,19 @@ $CWD = [Environment]::CurrentDirectory
Push-Location $MyInvocation.MyCommand.Path
[Environment]::CurrentDirectory = $PWD
# uninstall the bundler and clean up any artifacts.
cargo uninstall tauri-bundler
# clean up any artifacts.
cargo clean
# find any node_module folders.
$node_paths = Get-ChildItem -Path examples\ -Filter node_modules -Recurse -ErrorAction SilentlyContinue -Force
$node_paths = Get-ChildItem -Path smoke-tests\ -Filter node_modules -Recurse -ErrorAction SilentlyContinue -Force
if (-Not $node_paths -eq $null) {
# delete all of the node_module folders.
foreach ($path in $node_paths) {
$path.Delete()
}
# enter the examples folder and remove any changes.
cd $CWD/examples; git checkout -- .; git clean -dfX
# enter the smoke-tests folder and remove any changes.
cd $CWD/smoke-tests; git checkout -- .; git clean -dfX
}