fix: set identity keypair env variable for shuttle via secrets (#96) #91
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | |
has_tests: ${{ steps.set-matrix.outputs.has_tests }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- id: set-matrix | |
run: | | |
FOLDERS=$(ls -d tests/*/) | |
HAS_FOLDERS=$((${#FOLDERS[@]} > 0 ? 1 : 0)) | |
JSON_FOLDERS=$(echo "$FOLDERS" | jq -R -s -c 'split("\n")[:-1]') | |
echo "has_tests=$HAS_FOLDERS" >> $GITHUB_OUTPUT | |
echo "matrix={\"folder\":$JSON_FOLDERS}" >> $GITHUB_OUTPUT | |
build-znap: | |
name: Build Znap Cli | |
needs: [get-tests] | |
runs-on: ubuntu-latest | |
if: ${{ needs.get-tests.outputs.has_tests == 1 }} | |
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 && mkdir -p bin && mv ./target/release/znap bin | |
- uses: actions/upload-artifact@v4 | |
name: Upload Artifact | |
with: | |
name: znap-cli | |
path: bin/ | |
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 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Cache Node.js modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} | |
- uses: actions/download-artifact@v4 | |
id: download-cli | |
with: | |
path: /tmp/artifacts | |
- name: fix excecution file | |
run: chmod +x ${{ steps.download-cli.outputs.download-path }}/znap-cli/znap | |
- name: Install dependencies and run tests | |
id: prepare | |
run: | | |
echo "Installing dependencies..." | |
npm ci --prefix "${{ matrix.folder }}" | |
- name: Run Tests on folder ${{ matrix.folder }} | |
env: | |
ZNAP_LIB: ${{ github.workspace }}/znap | |
ZNAP_CWD: ${{ matrix.folder }} | |
IDENTITY_KEYPAIR: ${{ secrets.IDENTITY_KEYPAIR }} | |
run: | | |
echo "Running tests..." | |
cd "${{ matrix.folder }}" && ${{ steps.download-cli.outputs.download-path }}/znap-cli/znap test |