Skip to content

Commit

Permalink
Revise validate-rust-wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
giancosta86 committed Sep 3, 2024
1 parent 9312d72 commit c128fff
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: giancosta86/aurora-github/actions/tag-and-release@v2
2 changes: 1 addition & 1 deletion actions/publish-rust-wasm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ runs:
using: composite
steps:
- name: Set up NodeJS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: ${{ inputs.project-directory }}/client_tests/.nvmrc
registry-url: https://registry.npmjs.org
Expand Down
30 changes: 18 additions & 12 deletions actions/validate-rust-wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,42 @@ The action can be placed right after checking out the source code:
steps:
- uses: actions/checkout@v4

- uses: giancosta86/aurora-github/actions/validate-rust-crate
- uses: giancosta86/aurora-github/actions/validate-rust-wasm
```
## How it works
1. Optionally run [check-artifact-version](../check-artifact-version/README.md).
1. Invoke the [install-wasm-pack](../install-wasm-pack/README.md) action, passing all the matching inputs, to install the `wasm-pack` command

1. Display the version info for the main components of the Rust toolchain - ensuring the existence of `rust-toolchain.toml`.
1. Invoke the [validate-rust-crate](../validate-rust-crate/README.md) action, passing all the matching inputs, to perform code analysis over the Rust source code

1. Check the style of the Rust source files - via `cargo fmt`.
1. Run `wasm-pack test` to run headless browser tests

1. Lint via `cargo clippy`, enabling all features and targets. All warnings are considered errors.
1. If the `client-tests-directory` input parameter is not set to an empty string:

1. Run `cargo test` with no features.
1. Ensure the directory really exists

1. Run `cargo test` enabling all features.
1. Run `pnpm install` to install its dependencies

1. Run `pnpm test` to run the NodeJS-based client tests

## Requirements

- `rust-toolchain.toml` must be present in `project-directory` - as described in [print-rust-info](../print-rust-info/README.md)

- if the `client-tests-directory` input parameter is not set to an empty string, it must contain:
- if `client-tests-directory` is not set to an empty string, it must be the **relative path** of a directory containing:

- a `.nvmrc` file, containing the requested Node.js version
- a `.nvmrc` file, with the requested Node.js version

- a `package.json` descriptor containing:
- a `package.json` descriptor having:

- a `test` script, in the `scripts` section

- as usual, all the dependencies required by the test

- an updated `pnpm-lock.yaml` lockfile

It is worth mentioning that no quality checks - such as code formatting and linting - are performed on this test project
It is worth mentioning that no quality checks - such as code formatting and linting - are performed on this test project.

## Inputs

Expand All @@ -54,7 +58,9 @@ steps:

## Further references

- [check-artifact-version](../check-artifact-version/README.md)
- [install-wasm-pack](../install-wasm-pack/README.md)

- [validate-rust-crate](../validate-rust-crate/README.md)

- [print-rust-info](../print-rust-info/README.md)

Expand Down
13 changes: 6 additions & 7 deletions actions/validate-rust-wasm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Validates the source files of a Rust web assembly.
inputs:
client-tests-directory:
description: Relative directory containing the NodeJS-based client tests.
required: true
required: false
default: client-tests

check-artifact-version:
Expand All @@ -23,7 +23,7 @@ inputs:
default: bash

runs:
using: "composite"
using: composite
steps:
- name: Install wasm-pack
uses: giancosta86/aurora-github/install-wasm-pack
Expand All @@ -48,25 +48,24 @@ runs:
working-directory: ${{ inputs.project-directory }}
run: |
client_tests_directory="${{ inputs.client-tests-directory }}"
"
if [[ ! -d "$client_tests_directory" ]]
then
echo "The test directory '$client_tests_directory' does not exist"
echo "The client test directory '$client_tests_directory' does not exist"
exit 1
fi
- name: Set up NodeJS
if: ${{ inputs.client-tests-directory != '' }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: ${{ inputs.project-directory }}/${{ inputs.client-tests-directory }}/.nvmrc
registry-url: https://registry.npmjs.org

- name: Install client-side test dependencies
if: ${{ inputs.client-tests-directory != '' }}
shell: ${{ inputs.shell }}
working-directory: ${{ inputs.project-directory }}/${{ inputs.client-tests-directory }}
run: pnpm install --no-frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Perform client-side tests
if: ${{ inputs.client-tests-directory != '' }}
Expand Down

0 comments on commit c128fff

Please sign in to comment.