From a9de1ecdce0308fe6c538b4eb7d5a4c2674be904 Mon Sep 17 00:00:00 2001 From: Pedro Nauck Date: Sat, 24 Aug 2024 00:59:31 -0300 Subject: [PATCH] ci(repo): fix github actions --- .github/workflows/ci.yaml | 96 +++++++++---------- .github/workflows/publish_release.yaml | 33 +++++++ crates/fuel-data-parser/Cargo.toml | 1 + crates/fuel-streams-core/Cargo.toml | 1 + crates/fuel-streams-macros/Cargo.toml | 1 + .../subject-derive/Cargo.toml | 1 + knope.toml | 16 +++- package.json | 4 +- 8 files changed, 100 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/publish_release.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index eba26f06..c5a7a307 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -115,7 +115,6 @@ jobs: publish-crates-check: name: Publish Check needs: - - validate-title - lockfile - pre-commit - commitlint @@ -139,7 +138,6 @@ jobs: cargo-verifications: name: Cargo verifications needs: - - validate-title - lockfile - pre-commit - commitlint @@ -167,10 +165,10 @@ jobs: - name: Lint project run: make lint - test-coverage: + test: needs: - cargo-verifications - name: Test & Coverage + name: Test runs-on: ubuntu-latest env: NATS_URL: nats://127.0.0.1:4222 @@ -187,6 +185,8 @@ jobs: - name: Install Rust uses: ./.github/actions/setup-rust + with: + toolchain: ${{ env.RUST_NIGHTLY_VERSION }} - name: Start Nats run: | @@ -195,24 +195,54 @@ jobs: - name: Run tests run: make test + - name: Stop Nats + if: always() + run: make stop/nats + + test-coverage: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + needs: + - cargo-verifications + name: Test & Coverage + runs-on: ubuntu-latest + env: + NATS_URL: nats://127.0.0.1:4222 + NATS_ADMIN_PASS: secret + NATS_PUBLIC_PASS: secret + steps: + - uses: actions/checkout@v4 + + - name: Create .env file with NATS environment variables + run: | + echo "NATS_URL=${{ env.NATS_URL }}" > .env + echo "NATS_ADMIN_PASS=${{ env.NATS_ADMIN_PASS }}" >> .env + echo "NATS_PUBLIC_PASS=${{ env.NATS_PUBLIC_PASS }}" >> .env + + - name: Install Rust + uses: ./.github/actions/setup-rust + with: + toolchain: ${{ env.RUST_NIGHTLY_VERSION }} + target: x86_64-unknown-linux-gnu,wasm32-unknown-unknown + cache: false + + - name: Start Nats + run: | + make start/nats + - name: Install dependencies - if: github.event_name == 'push' && github.ref == 'refs/heads/main' run: | sudo apt-get update sudo apt-get install -y libclang-dev curl - name: Install Tarpaulin (Pre-built Binary) - if: github.event_name == 'push' && github.ref == 'refs/heads/main' uses: taiki-e/cache-cargo-install-action@v2 with: tool: cargo-tarpaulin@0.31 - name: Generate Code Coverage - if: github.event_name == 'push' && github.ref == 'refs/heads/main' run: make coverage - name: Upload to codecov.io - if: github.event_name == 'push' && github.ref == 'refs/heads/main' uses: codecov/codecov-action@v4 with: name: codecov-data-systems @@ -317,10 +347,13 @@ jobs: release: name: Create Release with Knope - if: (github.head_ref == 'changeset/release-main' && github.event.pull_request.merged == true) || github.event_name - == 'workflow_dispatch' + if: >- + (github.event_name == 'push' && + github.ref == 'refs/heads/main' && + contains(github.event.head_commit.message, 'ci(release): Preparing')) || + github.event_name == 'workflow_dispatch' needs: - - test-coverage + - test - build runs-on: ubuntu-latest permissions: @@ -328,10 +361,10 @@ jobs: actions: write steps: - name: Checkout Repository - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4 - name: Download Artifacts - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4 with: path: artifacts merge-multiple: true @@ -339,14 +372,6 @@ jobs: - name: List Artifacts run: ls -R artifacts - - name: Cache Artifacts - uses: actions/cache@v4 - with: - path: artifacts - key: ${{ runner.os }}-artifacts-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-artifacts- - - name: Run Knope Action uses: knope-dev/action@v2.1.0 with: @@ -355,31 +380,4 @@ jobs: - name: Knope Release run: knope release env: - github-token: ${{ secrets.REPO_TOKEN }} - - publish-crates: - name: Publish on Crates.io - needs: - - publish-crates-check - - release - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Restore Artifacts Cache - uses: actions/cache@v4 - with: - path: artifacts - key: ${{ runner.os }}-artifacts-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-artifacts- - - - name: Install Rust Toolchain - uses: dtolnay/rust-toolchain@master - - - name: Publish Crate - uses: FuelLabs/publish-crates@v1 - with: - publish-delay: 60000 - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} + GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} diff --git a/.github/workflows/publish_release.yaml b/.github/workflows/publish_release.yaml new file mode 100644 index 00000000..b4ad1d48 --- /dev/null +++ b/.github/workflows/publish_release.yaml @@ -0,0 +1,33 @@ +name: Publish on Crates.io + +on: + release: + types: + - published + +env: + CI: true + RUST_VERSION: 1.79.0 + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + publish-crates: + name: Publish on Crates.io + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_VERSION }} + target: x86_64-unknown-linux-gnu,wasm32-unknown-unknown + + - name: Publish Crate + uses: katyo/publish-crates@v2 + with: + publish-delay: 60000 + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/crates/fuel-data-parser/Cargo.toml b/crates/fuel-data-parser/Cargo.toml index 56d4f1d3..0104cc7f 100644 --- a/crates/fuel-data-parser/Cargo.toml +++ b/crates/fuel-data-parser/Cargo.toml @@ -1,5 +1,6 @@ [package] name = "fuel-data-parser" +description = "A parser for Fuel blockchain data structures and formats" authors = { workspace = true } keywords = { workspace = true } edition = { workspace = true } diff --git a/crates/fuel-streams-core/Cargo.toml b/crates/fuel-streams-core/Cargo.toml index 673fa837..1bd9750e 100644 --- a/crates/fuel-streams-core/Cargo.toml +++ b/crates/fuel-streams-core/Cargo.toml @@ -1,5 +1,6 @@ [package] name = "fuel-streams-core" +description = "Core components for working with streams of Fuel blockchain data" authors = { workspace = true } keywords = { workspace = true } edition = { workspace = true } diff --git a/crates/fuel-streams-macros/Cargo.toml b/crates/fuel-streams-macros/Cargo.toml index c6b3fa6c..f6effc1f 100644 --- a/crates/fuel-streams-macros/Cargo.toml +++ b/crates/fuel-streams-macros/Cargo.toml @@ -1,5 +1,6 @@ [package] name = "fuel-streams-macros" +description = "Macros for implementing traits and deriving functionality in the fuel-streams crate" authors = { workspace = true } keywords = { workspace = true } edition = { workspace = true } diff --git a/crates/fuel-streams-macros/subject-derive/Cargo.toml b/crates/fuel-streams-macros/subject-derive/Cargo.toml index 13487200..d17fa051 100644 --- a/crates/fuel-streams-macros/subject-derive/Cargo.toml +++ b/crates/fuel-streams-macros/subject-derive/Cargo.toml @@ -1,5 +1,6 @@ [package] name = "subject-derive" +description = "Derive macro for implementing the Subject trait in the fuel-streams crate" authors = { workspace = true } keywords = { workspace = true } edition = { workspace = true } diff --git a/knope.toml b/knope.toml index 4e201cad..c4733e6d 100644 --- a/knope.toml +++ b/knope.toml @@ -17,10 +17,22 @@ extra_changelog_sections = [ ] [[packages.fuel-streams.assets]] -path = "artifacts/fuel-streams-publisher-x86_64-unknown-linux-gnu.tgz" +path = "artifacts/fuel-streams-publisher-Linux-aarch64-gnu.tar.gz" [[packages.fuel-streams.assets]] -path = "artifacts/fuel-streams-x86_64-unknown-linux-gnu.tgz" +path = "artifacts/fuel-streams-publisher-Linux-aarch64-musl.tar.gz" + +[[packages.fuel-streams.assets]] +path = "artifacts/fuel-streams-publisher-Linux-x86_64-gnu.tar.gz" + +[[packages.fuel-streams.assets]] +path = "artifacts/fuel-streams-publisher-Linux-x86_64-musl.tar.gz" + +[[packages.fuel-streams.assets]] +path = "artifacts/fuel-streams-publisher-macOS-aarch64.tar.gz" + +[[packages.fuel-streams.assets]] +path = "artifacts/fuel-streams-publisher-macOS-x86_64.tar.gz" # ------------------------------------------------------------ # Workflow to get the current version diff --git a/package.json b/package.json index 6ecfd41d..d40b7dbe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "data-systems", - "version": "0.0.0", + "name": "fuel-streams", + "version": "0.0.1", "license": "MIT", "private": true, "scripts": {