diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 88d75be..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,99 +0,0 @@ -name: Build extensions - -on: - workflow_run: - workflows: ["Test extensions"] - types: - - completed - -concurrency: - group: ${{ github.workflow }} - cancel-in-progress: true - -jobs: - build: - name: Build extensions - if: ${{ github.event.workflow_run.conclusion == 'success' }} - env: - CARGO_COMPONENT_VERSION: "0.11.0" - SCCACHE_CACHE_SIZE: "2G" - SCCACHE_VERSION: "0.8.0" - RUSTC_WRAPPER: "/usr/local/bin/sccache" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Restore sccache cache - uses: actions/cache@v4 - with: - path: ~/.cache/sccache - key: ${{ runner.os }}-sccache-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-sccache- - - - name: Restore cargo cache - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry/index - ~/.cargo/registry/cache - ~/.cargo/git/db - ~/.cargo/bin - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- - - - name: Install sccache - run: | - if [ "${{ runner.os }}" = "Linux" ]; then - sccache_platform="x86_64-unknown-linux-musl" - elif [ "${{ runner.os }}" = "macOS" ]; then - sccache_platform="x86_64-apple-darwin" - elif [ "${{ runner.os }}" = "Windows" ]; then - sccache_platform="x86_64-pc-windows-msvc" - else - echo "Unsupported platform: ${{ runner.os }}" - exit 1 - fi - sccache_file="sccache-v${SCCACHE_VERSION}-${sccache_platform}" - sccache_url="https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/${sccache_file}.tar.gz" - echo "URL=${sccache_url}" - curl -L "$sccache_url" | tar xz - mv -f "$sccache_file/sccache" "$RUSTC_WRAPPER" - chmod +x "$RUSTC_WRAPPER" - - - name: Install wasm32-unknown-unknown target - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: stable - targets: wasm32-unknown-unknown - - - name: Install cargo-component - run: | - if ! command -v cargo-component || ! cargo-component --version | grep -q $CARGO_COMPONENT_VERSION; then - cargo install cargo-component --locked --version $CARGO_COMPONENT_VERSION --force - fi - - - name: Build extensions - run: cargo component build --release --workspace --target wasm32-unknown-unknown - - - name: Package extensions - run: .github/workflows/package.sh - - - name: Deploy to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4 - with: - branch: gh-pages - folder: gh-pages - commit-message: "Update extensions repository" - - - name: Upload packaged extensions as artifact - uses: actions/upload-artifact@v4 - with: - name: extensions - path: gh-pages/extensions/*.mix - if-no-files-found: ignore - - - name: Show sccache statistics - run: $RUSTC_WRAPPER --show-stats diff --git a/.github/workflows/test-and-build.yaml b/.github/workflows/test-and-build.yaml new file mode 100644 index 0000000..21ca842 --- /dev/null +++ b/.github/workflows/test-and-build.yaml @@ -0,0 +1,186 @@ +name: Build extensions + +on: + push: + branches: ['main'] + +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: true + +jobs: + test: + name: Test modified extensions + env: + CARGO_COMPONENT_VERSION: "0.11.0" + SCCACHE_CACHE_SIZE: "2G" + SCCACHE_VERSION: "0.8.0" + RUSTC_WRAPPER: "/usr/local/bin/sccache" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Restore sccache cache + uses: actions/cache@v4 + with: + path: ~/.cache/sccache + key: ${{ runner.os }}-sccache-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-sccache- + - name: Restore cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index + ~/.cargo/registry/cache + ~/.cargo/git/db + ~/.cargo/bin + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + - name: Install sccache + run: | + if [ "${{ runner.os }}" = "Linux" ]; then + sccache_platform="x86_64-unknown-linux-musl" + elif [ "${{ runner.os }}" = "macOS" ]; then + sccache_platform="x86_64-apple-darwin" + elif [ "${{ runner.os }}" = "Windows" ]; then + sccache_platform="x86_64-pc-windows-msvc" + else + echo "Unsupported platform: ${{ runner.os }}" + exit 1 + fi + sccache_file="sccache-v${SCCACHE_VERSION}-${sccache_platform}" + sccache_url="https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/${sccache_file}.tar.gz" + echo "URL=${sccache_url}" + curl -L "$sccache_url" | tar xz + mv -f "$sccache_file/sccache" "$RUSTC_WRAPPER" + chmod +x "$RUSTC_WRAPPER" + + - name: Install wasm32-unknown-unknown target + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: stable + targets: wasm32-unknown-unknown + + - name: Install cargo-component + run: | + if ! command -v cargo-component || ! cargo-component --version | grep -q $CARGO_COMPONENT_VERSION; then + cargo install cargo-component --locked --version $CARGO_COMPONENT_VERSION --force + fi + + - name: Run tests only on modified packages + run: | + changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) + changed_packages_dir=$(echo "$changed_files" | grep -o '^src/[^/]*/[^/]*' | sort -u) + if [ -z "$changed_packages_dir" ]; then + echo "No packages to test" + exit 0 + fi + while read -r package_dir; do + package_name=$(grep -oP -m 1 'name = "\K[^"]+' $package_dir/Cargo.toml) + echo "Running tests for $package_name" + cargo test --package $package_name + done <<< "$changed_packages_dir" + + - name: Show sccache statistics + run: $RUSTC_WRAPPER --show-stats + rustfmt: + needs: test + name: Check formatting + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Run `cargo fmt` + run: cargo fmt --all -- --check + build: + name: Build extensions + needs: rustfmt + env: + CARGO_COMPONENT_VERSION: "0.11.0" + SCCACHE_CACHE_SIZE: "2G" + SCCACHE_VERSION: "0.8.0" + RUSTC_WRAPPER: "/usr/local/bin/sccache" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Restore sccache cache + uses: actions/cache@v4 + with: + path: ~/.cache/sccache + key: ${{ runner.os }}-sccache-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-sccache- + + - name: Restore cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index + ~/.cargo/registry/cache + ~/.cargo/git/db + ~/.cargo/bin + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Install sccache + run: | + if [ "${{ runner.os }}" = "Linux" ]; then + sccache_platform="x86_64-unknown-linux-musl" + elif [ "${{ runner.os }}" = "macOS" ]; then + sccache_platform="x86_64-apple-darwin" + elif [ "${{ runner.os }}" = "Windows" ]; then + sccache_platform="x86_64-pc-windows-msvc" + else + echo "Unsupported platform: ${{ runner.os }}" + exit 1 + fi + sccache_file="sccache-v${SCCACHE_VERSION}-${sccache_platform}" + sccache_url="https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/${sccache_file}.tar.gz" + echo "URL=${sccache_url}" + curl -L "$sccache_url" | tar xz + mv -f "$sccache_file/sccache" "$RUSTC_WRAPPER" + chmod +x "$RUSTC_WRAPPER" + + - name: Install wasm32-unknown-unknown target + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: stable + targets: wasm32-unknown-unknown + + - name: Install cargo-component + run: | + if ! command -v cargo-component || ! cargo-component --version | grep -q $CARGO_COMPONENT_VERSION; then + cargo install cargo-component --locked --version $CARGO_COMPONENT_VERSION --force + fi + + - name: Build extensions + run: cargo component build --release --workspace --target wasm32-unknown-unknown + + - name: Package extensions + run: .github/workflows/package.sh + + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: gh-pages + commit-message: "Update extensions repository" + + - name: Upload packaged extensions as artifact + uses: actions/upload-artifact@v4 + with: + name: extensions + path: gh-pages/extensions/*.mix + if-no-files-found: ignore + + - name: Show sccache statistics + run: $RUSTC_WRAPPER --show-stats diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 62940c5..e0d2c52 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,19 +1,15 @@ name: Test extensions on: - push: - branches: - - main - paths: - - 'src/**' - - '.github/workflows/test.yaml' + pull_request: + branches: ['main'] concurrency: group: ${{ github.workflow }} cancel-in-progress: true jobs: - build: + test: name: Test modified extensions env: CARGO_COMPONENT_VERSION: "0.11.0" diff --git a/.gitignore b/.gitignore index ea8c4bf..198c4ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /target + +.idea/