Skip to content

Commit

Permalink
setup ci (#19)
Browse files Browse the repository at this point in the history
* setup ci

* fix scripts

* remove chmod

* fix build

* action cache

* fix code
  • Loading branch information
qiweiii authored Jun 17, 2024
1 parent 3085447 commit 0cb3695
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 34 deletions.
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

0 comments on commit 0cb3695

Please sign in to comment.