Skip to content

Commit

Permalink
rework workflow structure
Browse files Browse the repository at this point in the history
  • Loading branch information
enitrat committed Sep 30, 2024
1 parent 99d261f commit 15dbb4e
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 59 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Reusable Build Workflow

on:
workflow_call:
inputs:
artifact-name:
required: true
type: string

permissions: read-all

jobs:
build:
runs-on: ubuntu-latest
env:
CI_COMMIT_MESSAGE: CI Formatting Auto Commit
CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} CI
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Scarb
uses: software-mansion/setup-scarb@v1

- name: Build contracts
run: scarb build -p contracts

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact-name }}
path: target/dev
23 changes: 11 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,24 @@ permissions: read-all

jobs:
build:
uses: ./.github/workflows/common.yml#build
uses: ./.github/workflows/build.yml
with:
artifact-name: kakarot-ssj-build

tests-unit:
# trunk-ignore(actionlint/runner-label)
runs-on: ubuntu-latest-16-cores
steps:
- uses: actions/checkout@v3
- uses: foundry-rs/setup-snfoundry@v3
- uses: software-mansion/setup-scarb@v1
- run: scarb fmt --check
- run: scarb build
- run: scarb test
uses: ./.github/workflows/tests-unit.yml
with:
run-fmt-check: false

ef-tests:
uses: ./.github/workflows/common.yml#ef-tests
uses: ./.github/workflows/ef-tests.yml
needs: [build]
with:
artifact-name: kakarot-ssj-build

resources:
runs-on: ubuntu-latest
needs: ef-tests
needs: [ef-tests]
steps:
- uses: actions/checkout@v4

Expand Down
38 changes: 12 additions & 26 deletions .github/workflows/common.yml → .github/workflows/ef-tests.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,18 @@
name: Common Workflow
name: EF-Tests

on:
workflow_call:
inputs:
artifact-name:
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
env:
CI_COMMIT_MESSAGE: CI Formatting Auto Commit
CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} CI
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Scarb
uses: software-mansion/setup-scarb@v1
permissions: read-all

- name: Build contracts
run: scarb build -p contracts

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: kakarot-ssj-build
path: target/dev

ef-tests:
jobs:
ef-tests:
# trunk-ignore(actionlint/runner-label)
runs-on: ubuntu-latest-16-cores
needs: [build]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -44,7 +28,9 @@ jobs:
~/.cargo/git/db/
target/
./libcairo_native_runtime.a
key: ${{ runner.os }}-cairo-native-${{ hashFiles('**/Cargo.lock', 'scripts/setup_cairo_native.sh') }}
key:
${{ runner.os }}-cairo-native-${{ hashFiles('**/Cargo.lock',
'scripts/setup_cairo_native.sh') }}

- name: Make setup script executable
run: chmod +x ./scripts/setup_cairo_native.sh
Expand Down Expand Up @@ -92,7 +78,7 @@ jobs:
- name: Download Kakarot-SSJ build artifacts in v1
uses: actions/download-artifact@v3
with:
name: kakarot-ssj-build
name: ${{ inputs.artifact-name }}
path: ef-tests/build/v1

- name: Move Cairo1Helpers
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ concurrency:

jobs:
build:
uses: ./.github/workflows/common.yml#build
uses: ./.github/workflows/build.yml
with:
artifact-name: kakarot-ssj-build

tests:
# trunk-ignore(actionlint/runner-label)
runs-on: ubuntu-latest-16-cores
steps:
- uses: actions/checkout@v3
- uses: foundry-rs/setup-snfoundry@v3
- uses: software-mansion/setup-scarb@v1
- run: scarb fmt --check
- run: scarb test
tests-unit:
uses: ./.github/workflows/tests-unit.yml
with:
run-fmt-check: true

ef-tests:
uses: ./.github/workflows/common.yml#ef-tests
uses: ./.github/workflows/ef-tests.yml
needs: [build]
with:
artifact-name: kakarot-ssj-build
26 changes: 26 additions & 0 deletions .github/workflows/tests-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Reusable Unit Tests Workflow

on:
workflow_call:
inputs:
run-fmt-check:
type: boolean
default: false
required: false

permissions: read-all

jobs:
unit-tests:
runs-on: ubuntu-latest-16-cores # trunk-ignore(actionlint/runner-label)
steps:
- uses: actions/checkout@v4
- uses: foundry-rs/setup-snfoundry@v3
- uses: software-mansion/setup-scarb@v1

- name: Run format check
if: inputs.run-fmt-check
run: scarb fmt --check

- name: Run tests
run: scarb test
25 changes: 15 additions & 10 deletions scripts/setup_cairo_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,28 +143,33 @@ main() {
SKIP_RUNTIME=false
while getopts ":s" opt; do
case ${opt} in
s )
SKIP_RUNTIME=true
;;
\? )
echo "Invalid option: $OPTARG" 1>&2
exit 1
;;
s)
SKIP_RUNTIME=true
;;
\?)
echo "Invalid option: ${OPTARG}" 1>&2
exit 1
;;
*)
echo "Error: Unhandled option" 1>&2
exit 1
;;
esac
done
shift $((OPTIND -1))
shift $((OPTIND - 1))

# shellcheck disable=SC2312
[[ "$(uname)" == "Linux" ]] && install_essential_deps_linux

setup_llvm_deps

if [ "$SKIP_RUNTIME" = false ]; then
if [[ ${SKIP_RUNTIME} == false ]]; then
install_cairo_native_runtime
else
echo "Skipping Cairo native runtime installation"
# Set the environment variable if the library file exists
if [ -f "$(pwd)/libcairo_native_runtime.a" ]; then
# shellcheck disable=SC2312
if [[ -f "$(pwd)/libcairo_native_runtime.a" ]]; then
CAIRO_NATIVE_RUNTIME_LIBRARY=$(pwd)/libcairo_native_runtime.a
export CAIRO_NATIVE_RUNTIME_LIBRARY
echo "CAIRO_NATIVE_RUNTIME_LIBRARY=${CAIRO_NATIVE_RUNTIME_LIBRARY}"
Expand Down

0 comments on commit 15dbb4e

Please sign in to comment.