Skip to content

Commit

Permalink
ci(repo): fix github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Aug 24, 2024
1 parent a248c45 commit a9de1ec
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 53 deletions.
96 changes: 47 additions & 49 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ jobs:
publish-crates-check:
name: Publish Check
needs:
- validate-title
- lockfile
- pre-commit
- commitlint
Expand All @@ -139,7 +138,6 @@ jobs:
cargo-verifications:
name: Cargo verifications
needs:
- validate-title
- lockfile
- pre-commit
- commitlint
Expand Down Expand Up @@ -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
Expand All @@ -187,6 +185,8 @@ jobs:
- name: Install Rust
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ env.RUST_NIGHTLY_VERSION }}

- name: Start Nats
run: |
Expand All @@ -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: [email protected]

- 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
Expand Down Expand Up @@ -317,36 +347,31 @@ 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:
contents: read
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

- 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/[email protected]
with:
Expand All @@ -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 }}
33 changes: 33 additions & 0 deletions .github/workflows/publish_release.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 1 addition & 0 deletions crates/fuel-data-parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
1 change: 1 addition & 0 deletions crates/fuel-streams-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
1 change: 1 addition & 0 deletions crates/fuel-streams-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
1 change: 1 addition & 0 deletions crates/fuel-streams-macros/subject-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
16 changes: 14 additions & 2 deletions knope.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "data-systems",
"version": "0.0.0",
"name": "fuel-streams",
"version": "0.0.1",
"license": "MIT",
"private": true,
"scripts": {
Expand Down

0 comments on commit a9de1ec

Please sign in to comment.