Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup ci #19

Merged
merged 7 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]


jobs:
lint:
name: Swift Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Check swift codestyle
uses: norio-nomura/action-swiftlint@3.2.1
with:
args: lint --config .swiftlint.yml --strict

test:
name: Build and Test
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: "5.10"
- name: Run Script
run: |
chmod +x ./scripts/build-and-test.sh
./scripts/build-and-test.sh
42 changes: 42 additions & 0 deletions scripts/build-and-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Function to build a package
build_package() {
local package_path=$1
local package_name=$(basename "$package_path")
echo "Building $package_name..."
swift build --package-path "$package_path"
if [ $? -eq 0 ]; then
echo -e "$package_name build successful. \n"
else
echo "$package_name build failed!"
exit 1
fi
}

# Function to test a package
test_package() {
local package_path=$1
local package_name=$(basename "$package_path")
echo "Testing $package_name..."
swift test --package-path "$package_path"
if [ $? -eq 0 ]; then
echo -e "$package_name tests passed. \n"
else
echo "$package_name tests failed!"
exit 1
fi
}

# List of package paths
packages=( "./Blockchain" "./Boka" "./Database" "./Node" "./Utils" )
qiweiii marked this conversation as resolved.
Show resolved Hide resolved

for package_path in "${packages[@]}"; do
build_package "$package_path"
done

for package_path in "${packages[@]}"; do
test_package "$package_path"
done

echo "All packages built and tested successfully."
Loading