Skip to content

Commit

Permalink
Add CI
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
  • Loading branch information
rylev committed May 23, 2024
1 parent 95b0e07 commit 273f6f6
Show file tree
Hide file tree
Showing 12 changed files with 504 additions and 12 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI
on:
push:
branches: ["main"]
paths-ignore:
- "*.md"
- "LICENSE"
pull_request:
branches: ["main"]
paths-ignore:
- ".plugin-manifests/**"
- "*.md"
- "LICENSE"

env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.78
jobs:
lint-rust:
name: Lint Rust
runs-on: "ubuntu-latest"
steps:
- name: Install Rust toolchain
run: |
rustup toolchain install ${{ env.RUST_VERSION }} --component clippy --component rustfmt
rustup default ${{ env.RUST_VERSION }}
- name: Install Wasm Rust target
run: rustup target add wasm32-wasi && rustup target add wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-full-${{ hashFiles('./Cargo.lock') }}"
- uses: actions/checkout@v4
- name: Cargo Format
run:
cargo fmt --all -- --check
- name: Cargo Clippy
run:
cargo clippy --workspace --all-targets --all-features -- -D warnings
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Create and Upload Release

on:
push:
branches:
- main

env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.78

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust toolchain
shell: bash
run: |
rustup toolchain install ${{ env.RUST_VERSION }} --component rustfmt
rustup default ${{ env.RUST_VERSION }}
- name: Install Wasm Rust target
run: rustup target add wasm32-wasi && rustup target add wasm32-unknown-unknown
- name: Create archive
run: ./archive.sh
- name: Upload release artifact
uses: actions/upload-artifact@v4
with:
name: tests
path: tests.tar.gz

- name: Recreate canary release
uses: ncipollo/release-action@v1.14.0
with:
tag: canary
allowUpdates: true
prerelease: true
artifacts: "tests.tar.gz"
commit: ${{ github.sha }}
body: |
This is a "canary" release of the most recent commits on our main branch. Canary is **not stable**.
File renamed without changes.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
members = ["tests/*"]
resolver = "2"
47 changes: 47 additions & 0 deletions archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Creates a tarball containing the compiled WebAssembly test binaries,
# along with their configuration and manifest files.

set -e

OUTPUT_TAR="tests.tar.gz"

# Create a temporary directory to store the files to be archived
TEMP_DIR=$(mktemp -d)
touch "$TEMP_DIR/.gitkeep"

# Loop over each subdirectory in the base directory
for SUBDIR in tests/*/; do
# Check if it is indeed a directory
if [ -d "$SUBDIR" ]; then
echo "Processing $SUBDIR..."

# Navigate into the subdirectory
cd "$SUBDIR"
BASENAME=$(basename "$SUBDIR")

# Create a directory in the temporary directory to store the files
mkdir -p "$TEMP_DIR/$BASENAME/target/wasm32-unknown-unknown/release"

# Build the test, and copy the build artifact to the temporary directory
cargo build --release --target=wasm32-unknown-unknown --target-dir=target
BUILD_ARTIFACT=$(find target/wasm32-unknown-unknown/release -maxdepth 1 -type f -name "*.wasm")
cp "$BUILD_ARTIFACT" "$TEMP_DIR/$BASENAME/target/wasm32-unknown-unknown/release"

# Copy the configuration and manifest files to the temporary directory
cp test.json5 "$TEMP_DIR/$BASENAME"
cp spin.toml "$TEMP_DIR/$BASENAME"

# Navigate back to the base directory
cd - > /dev/null
fi
done

# Create the tarball from the temporary directory
tar -czf "$OUTPUT_TAR" -C "$TEMP_DIR" .

# Clean up the temporary directory
rm -rf "$TEMP_DIR"

echo "Tarball created: $OUTPUT_TAR"
File renamed without changes.
Loading

0 comments on commit 273f6f6

Please sign in to comment.