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 all commits
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
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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
- uses: actions/cache@v3
with:
path: '**/.build'
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Setup Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: "5.10"
- name: Run Script
run: |
make test
25 changes: 0 additions & 25 deletions Boka/Database/Package.swift

This file was deleted.

2 changes: 0 additions & 2 deletions Boka/Database/Sources/Database/Database.swift

This file was deleted.

4 changes: 4 additions & 0 deletions Boka/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ let package = Package(
.product(name: "ArgumentParser", package: "swift-argument-parser"),
]
),
.testTarget(
name: "BokaTests",
dependencies: ["Boka"]
),
]
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import XCTest

@testable import Database
@testable import Boka

final class DatabaseTests: XCTestCase {
final class BokaTests: XCTestCase {
func testExample() throws {
// XCTest Documentation
// https://developer.apple.com/documentation/xctest
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.PHONY: githooks
githooks:
cp .githooks/pre-commit .git/hooks/pre-commit

test: githooks
./scripts/run.sh test
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import XCTest

@testable import Utils

final class H256Tests: XCTestCase {
final class Data32Tests: XCTestCase {
func testZero() throws {
let value = H256.zero
let value = Data32()
XCTAssertEqual(value.data, Data(repeating: 0, count: 32))
XCTAssertEqual(
value.description, "0x0000000000000000000000000000000000000000000000000000000000000000"
Expand All @@ -16,15 +16,15 @@ final class H256Tests: XCTestCase {
for i in 0 ..< 32 {
data[i] = UInt8(i)
}
let value = H256(data)!
let value = Data32(data)!
XCTAssertEqual(value.data, data)
XCTAssertEqual(
value.description, "0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"
)
}

func testInitWithInvalidData() throws {
XCTAssertNil(H256(Data(repeating: 0, count: 31)))
XCTAssertNil(H256(Data(repeating: 0, count: 33)))
XCTAssertNil(Data32(Data(repeating: 0, count: 31)))
XCTAssertNil(Data32(Data(repeating: 0, count: 33)))
}
}
13 changes: 13 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -e

COMMAND=$1

shift

set -x

for file in **/Package.swift; do
swift $COMMAND $@ --package-path "$(dirname "$file")";
done
Loading