Skip to content

Commit

Permalink
Fix ci (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajjon authored Mar 25, 2023
1 parent 722e6cc commit 94bc63e
Show file tree
Hide file tree
Showing 63 changed files with 3,822 additions and 3,839 deletions.
57 changes: 36 additions & 21 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- '*'
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- '*'
workflow_dispatch:

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
library:
runs-on: macos-12
strategy:
matrix:
xcode: ['13.4.1', '14.0.1']
config: ['debug', 'release']
steps:
- uses: actions/checkout@v3
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Run ${{ matrix.config }} tests
run: CONFIG=${{ matrix.config }} make test-library
linting:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- name: "Run Lint"
run: |
brew update
brew upgrade swiftformat
swiftformat . --lint
unittest:
runs-on: macos-12
needs:
- linting
strategy:
matrix:
xcode: ['14.1']
steps:
- uses: actions/checkout@v3
- name: "Select Xcode ${{ matrix.xcode }}"
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: "Clean and init submodules"
run: make init
- name: "Run test in debug"
run: make testdebug
- name: "Run test in production"
run: make testprod
16 changes: 16 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--swiftversion 5.6

# format options
--allman false # Prefer `K&R` https://en.wikipedia.org/wiki/Indentation_style#K&R_style
--indent tab
--tabwidth 4

--stripunusedargs closure-only
--enable marktypes
--disable redundantNilInit,redundantSelf,extensionAccessControl
--lineaftermarks false
--ifdef no-indent
--header strip

# file options
--exclude .build,Sources/secp256k1,Sources/K1/Support/ThirdyParty
47 changes: 37 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,45 @@ PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst
PLATFORM_TVOS = tvOS Simulator,name=Apple TV
PLATFORM_WATCHOS = watchOS Simulator,name=Apple Watch Series 7 (45mm)

default: test-all
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))

test-all: test-library
.PHONY: submodules test dev clean testprod testdebug purge init format formatstaged

test-library:
rmsubmod:
rm -rf "$(ROOT_DIR)Sources/secp256k1/libsecp256k1"

clean:
rm -rf .build

purge:
make rmsubmod
make clean

submodules: ## Update all sumodules .
git submodule update --init

init:
make purge
make submodules

dev:
./scripts/bootstrap
make init

test:
make clean
make testdebug
make clean
make testprod

testdebug:
swift test

testprod:
swift test -c release -Xswiftc -enable-testing

format:
swift format \
--ignore-unparsable-files \
--in-place \
--recursive \
./Examples ./Package.swift ./Sources ./Tests
formatstaged:
./scripts/swiftformat-staged

.PHONY: format test-all
format:
swiftformat --config .swiftformat "$(ROOT_DIR)"
171 changes: 85 additions & 86 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,97 +6,96 @@ import PackageDescription
let development = false

let cSettings: [CSetting] = [
// Basic config values that are universal and require no dependencies.
// https://github.com/bitcoin-core/secp256k1/blob/master/src/basic-config.h#L12-L13
.define("ECMULT_WINDOW_SIZE", to: "15"),
.define("ECMULT_GEN_PREC_BITS", to: "4"),
// Basic config values that are universal and require no dependencies.
// https://github.com/bitcoin-core/secp256k1/blob/master/src/basic-config.h#L12-L13
.define("ECMULT_WINDOW_SIZE", to: "15"),
.define("ECMULT_GEN_PREC_BITS", to: "4"),

// Enable modules in secp256k1, for list scroll down to bottom of:
// Sources/secp256k1/libsecp256k1/src/secp256k1.c
.define("ENABLE_MODULE_ECDH"),
.define("ENABLE_MODULE_RECOVERY"),
.define("ENABLE_MODULE_SCHNORRSIG"),
.define("ENABLE_MODULE_EXTRAKEYS"),
// Enable modules in secp256k1, for list scroll down to bottom of:
// Sources/secp256k1/libsecp256k1/src/secp256k1.c
.define("ENABLE_MODULE_ECDH"),
.define("ENABLE_MODULE_RECOVERY"),
.define("ENABLE_MODULE_SCHNORRSIG"),
.define("ENABLE_MODULE_EXTRAKEYS"),
]

let package = Package(
name: "K1",
platforms: [
.iOS(.v13),
.macOS(.v11),
.tvOS(.v13),
.watchOS(.v6),
],
products: [
.library(
name: "K1",
targets: [
"K1"
]
),
],
dependencies: [],
targets: [

// Target `libsecp256k1` https://github.com/bitcoin-core/secp256k1
.target(
name: "secp256k1",
exclude: [
"libsecp256k1/src/asm",
"libsecp256k1/src/bench.c",
"libsecp256k1/src/bench_ecmult.c",
"libsecp256k1/src/bench_internal.c",
"libsecp256k1/src/modules/extrakeys/tests_impl.h",
"libsecp256k1/src/modules/schnorrsig/tests_impl.h",
"libsecp256k1/src/precompute_ecmult.c",
"libsecp256k1/src/precompute_ecmult_gen.c",
"libsecp256k1/src/tests_exhaustive.c",
"libsecp256k1/src/tests.c",
"libsecp256k1/src/ctime_tests.c",

"libsecp256k1/examples/",

"libsecp256k1/autogen.sh",
"libsecp256k1/CMakeLists.txt",
"libsecp256k1/configure.ac",
"libsecp256k1/COPYING",
"libsecp256k1/libsecp256k1.pc.in",
"libsecp256k1/Makefile.am",
"libsecp256k1/README.md",
"libsecp256k1/SECURITY.md"
],
cSettings: cSettings
),
.target(
name: "K1",
dependencies: [
"secp256k1",
],
swiftSettings: [
.define("CRYPTO_IN_SWIFTPM_FORCE_BUILD_API"),
]
),
.testTarget(
name: "K1Tests",
dependencies: [
"K1",
],
resources: [
.process("TestVectors/"),
]
),
]
name: "K1",
platforms: [
.iOS(.v13),
.macOS(.v11),
.tvOS(.v13),
.watchOS(.v6),
],
products: [
.library(
name: "K1",
targets: [
"K1",
]
),
],
dependencies: [],
targets: [
// Target `libsecp256k1` https://github.com/bitcoin-core/secp256k1
.target(
name: "secp256k1",
exclude: [
"libsecp256k1/src/asm",
"libsecp256k1/src/bench.c",
"libsecp256k1/src/bench_ecmult.c",
"libsecp256k1/src/bench_internal.c",
"libsecp256k1/src/modules/extrakeys/tests_impl.h",
"libsecp256k1/src/modules/schnorrsig/tests_impl.h",
"libsecp256k1/src/precompute_ecmult.c",
"libsecp256k1/src/precompute_ecmult_gen.c",
"libsecp256k1/src/tests_exhaustive.c",
"libsecp256k1/src/tests.c",
"libsecp256k1/src/ctime_tests.c",

"libsecp256k1/examples/",

"libsecp256k1/autogen.sh",
"libsecp256k1/CMakeLists.txt",
"libsecp256k1/configure.ac",
"libsecp256k1/COPYING",
"libsecp256k1/libsecp256k1.pc.in",
"libsecp256k1/Makefile.am",
"libsecp256k1/README.md",
"libsecp256k1/SECURITY.md",
],
cSettings: cSettings
),
.target(
name: "K1",
dependencies: [
"secp256k1",
],
swiftSettings: [
.define("CRYPTO_IN_SWIFTPM_FORCE_BUILD_API"),
]
),
.testTarget(
name: "K1Tests",
dependencies: [
"K1",
],
resources: [
.process("TestVectors/"),
]
),
]
)

if development {
for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(
.unsafeFlags([
"-Xfrontend", "-warn-concurrency",
"-Xfrontend", "-enable-actor-data-race-checks",
"-enable-library-evolution",
])
)
}
for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(
.unsafeFlags([
"-Xfrontend", "-warn-concurrency",
"-Xfrontend", "-enable-actor-data-race-checks",
"-enable-library-evolution",
])
)
}
}
2 changes: 1 addition & 1 deletion Sources/K1/K1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import Foundation

/// The Elliptic Curve `secp256k1`
public enum K1 {
// The namespace for all structs and operations vendored by this library.
// The namespace for all structs and operations vendored by this library.
}
Loading

0 comments on commit 94bc63e

Please sign in to comment.