Skip to content

Generate First tests case #21

Generate First tests case

Generate First tests case #21

Workflow file for this run

name: CI
on:
workflow_call:
workflow_dispatch:
push:
branches:
- main
- master
paths-ignore:
- "LICENSE*"
- "**.md"
- "**.png"
tags-ignore:
- "**"
pull_request:
branches:
- main
- master
- dev
paths-ignore:
- "LICENSE*"
- "**.md"
- "**.png"
jobs:
# Run cargo clippy -- -D warnings
clippy_check:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@stable
- name: Run clippy
run: cargo clippy -- -D warnings
# Run cargo fmt --all -- --check
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Run cargo fmt
run: cargo fmt --all -- --check
# Run cargo test
test:
name: Run API Tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@stable
- name: Run tests
run: cargo test
get-tests:
name: Get all Tests as output
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
files: ${{ steps.list-tests.outputs.files }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- id: set-matrix
run: |
FOLDERS=$(ls -d tests/*/ | jq -R -s -c 'split("\n")[:-1]')
echo "matrix={\"folder\":$FOLDERS}" >> $GITHUB_OUTPUT
- name: List tests files
id: list-tests
run: |
echo "files=$(ls -d tests/*/)" >> $GITHUB_OUTPUT
build-znap:
name: Build Znap Cli
needs: [get-tests]
runs-on: ubuntu-latest
if: ${{ needs.get-tests.outputs.files != '' }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo b -r -p znap-cli
- uses: actions/upload-artifact@v3
name: Upload Artifact
with:
name: znap-cli
path: ./target/release/znap
retention-days: 1
run-tests:
name: Run Tests
needs: [get-tests, build-znap]
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.get-tests.outputs.matrix) }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@stable
- uses: actions/download-artifact@v3
id: download-cli
with:
name: znap-cli
- name: fix excecution file
run: |
ls ${{ steps.download-cli.outputs.download-path }}
echo "-------"
ls ${{ steps.download-cli.outputs.download-path }}/znap
echo "-------"
chmod +x ${{ steps.download-cli.outputs.download-path }}/znap/znap
- name: Run Tests on folder ${{ matrix.folder }}
env:
ZNAP_LIB: ${{ github.workspace }}/znap
run: |
echo "Running tests..."
cd "${{ matrix.folder }}" && ${{ steps.download-cli.outputs.download-path }}/znap/znap test