Skip to content

Commit 94bc63e

Browse files
authored
Fix ci (#21)
1 parent 722e6cc commit 94bc63e

File tree

63 files changed

+3822
-3839
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3822
-3839
lines changed

.github/workflows/swift.yml

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,43 @@
11
name: CI
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- '*'
10-
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- '*'
10+
workflow_dispatch:
1111

1212
concurrency:
13-
group: ci-${{ github.ref }}
14-
cancel-in-progress: true
13+
group: ci-${{ github.ref }}
14+
cancel-in-progress: true
1515

1616
jobs:
17-
library:
18-
runs-on: macos-12
19-
strategy:
20-
matrix:
21-
xcode: ['13.4.1', '14.0.1']
22-
config: ['debug', 'release']
23-
steps:
24-
- uses: actions/checkout@v3
25-
- name: Select Xcode ${{ matrix.xcode }}
26-
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
27-
- name: Run ${{ matrix.config }} tests
28-
run: CONFIG=${{ matrix.config }} make test-library
17+
linting:
18+
runs-on: macos-12
19+
steps:
20+
- uses: actions/checkout@v3
21+
- name: "Run Lint"
22+
run: |
23+
brew update
24+
brew upgrade swiftformat
25+
swiftformat . --lint
26+
27+
unittest:
28+
runs-on: macos-12
29+
needs:
30+
- linting
31+
strategy:
32+
matrix:
33+
xcode: ['14.1']
34+
steps:
35+
- uses: actions/checkout@v3
36+
- name: "Select Xcode ${{ matrix.xcode }}"
37+
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
38+
- name: "Clean and init submodules"
39+
run: make init
40+
- name: "Run test in debug"
41+
run: make testdebug
42+
- name: "Run test in production"
43+
run: make testprod

.swiftformat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--swiftversion 5.6
2+
3+
# format options
4+
--allman false # Prefer `K&R` https://en.wikipedia.org/wiki/Indentation_style#K&R_style
5+
--indent tab
6+
--tabwidth 4
7+
8+
--stripunusedargs closure-only
9+
--enable marktypes
10+
--disable redundantNilInit,redundantSelf,extensionAccessControl
11+
--lineaftermarks false
12+
--ifdef no-indent
13+
--header strip
14+
15+
# file options
16+
--exclude .build,Sources/secp256k1,Sources/K1/Support/ThirdyParty

Makefile

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,45 @@ PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst
44
PLATFORM_TVOS = tvOS Simulator,name=Apple TV
55
PLATFORM_WATCHOS = watchOS Simulator,name=Apple Watch Series 7 (45mm)
66

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

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

11-
test-library:
11+
rmsubmod:
12+
rm -rf "$(ROOT_DIR)Sources/secp256k1/libsecp256k1"
13+
14+
clean:
15+
rm -rf .build
16+
17+
purge:
18+
make rmsubmod
19+
make clean
20+
21+
submodules: ## Update all sumodules .
22+
git submodule update --init
23+
24+
init:
25+
make purge
26+
make submodules
27+
28+
dev:
29+
./scripts/bootstrap
30+
make init
31+
32+
test:
33+
make clean
34+
make testdebug
35+
make clean
36+
make testprod
37+
38+
testdebug:
1239
swift test
40+
41+
testprod:
42+
swift test -c release -Xswiftc -enable-testing
1343

14-
format:
15-
swift format \
16-
--ignore-unparsable-files \
17-
--in-place \
18-
--recursive \
19-
./Examples ./Package.swift ./Sources ./Tests
44+
formatstaged:
45+
./scripts/swiftformat-staged
2046

21-
.PHONY: format test-all
47+
format:
48+
swiftformat --config .swiftformat "$(ROOT_DIR)"

Package.swift

Lines changed: 85 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -6,97 +6,96 @@ import PackageDescription
66
let development = false
77

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

14-
// Enable modules in secp256k1, for list scroll down to bottom of:
15-
// Sources/secp256k1/libsecp256k1/src/secp256k1.c
16-
.define("ENABLE_MODULE_ECDH"),
17-
.define("ENABLE_MODULE_RECOVERY"),
18-
.define("ENABLE_MODULE_SCHNORRSIG"),
19-
.define("ENABLE_MODULE_EXTRAKEYS"),
14+
// Enable modules in secp256k1, for list scroll down to bottom of:
15+
// Sources/secp256k1/libsecp256k1/src/secp256k1.c
16+
.define("ENABLE_MODULE_ECDH"),
17+
.define("ENABLE_MODULE_RECOVERY"),
18+
.define("ENABLE_MODULE_SCHNORRSIG"),
19+
.define("ENABLE_MODULE_EXTRAKEYS"),
2020
]
2121

2222
let package = Package(
23-
name: "K1",
24-
platforms: [
25-
.iOS(.v13),
26-
.macOS(.v11),
27-
.tvOS(.v13),
28-
.watchOS(.v6),
29-
],
30-
products: [
31-
.library(
32-
name: "K1",
33-
targets: [
34-
"K1"
35-
]
36-
),
37-
],
38-
dependencies: [],
39-
targets: [
40-
41-
// Target `libsecp256k1` https://github.com/bitcoin-core/secp256k1
42-
.target(
43-
name: "secp256k1",
44-
exclude: [
45-
"libsecp256k1/src/asm",
46-
"libsecp256k1/src/bench.c",
47-
"libsecp256k1/src/bench_ecmult.c",
48-
"libsecp256k1/src/bench_internal.c",
49-
"libsecp256k1/src/modules/extrakeys/tests_impl.h",
50-
"libsecp256k1/src/modules/schnorrsig/tests_impl.h",
51-
"libsecp256k1/src/precompute_ecmult.c",
52-
"libsecp256k1/src/precompute_ecmult_gen.c",
53-
"libsecp256k1/src/tests_exhaustive.c",
54-
"libsecp256k1/src/tests.c",
55-
"libsecp256k1/src/ctime_tests.c",
56-
57-
"libsecp256k1/examples/",
58-
59-
"libsecp256k1/autogen.sh",
60-
"libsecp256k1/CMakeLists.txt",
61-
"libsecp256k1/configure.ac",
62-
"libsecp256k1/COPYING",
63-
"libsecp256k1/libsecp256k1.pc.in",
64-
"libsecp256k1/Makefile.am",
65-
"libsecp256k1/README.md",
66-
"libsecp256k1/SECURITY.md"
67-
],
68-
cSettings: cSettings
69-
),
70-
.target(
71-
name: "K1",
72-
dependencies: [
73-
"secp256k1",
74-
],
75-
swiftSettings: [
76-
.define("CRYPTO_IN_SWIFTPM_FORCE_BUILD_API"),
77-
]
78-
),
79-
.testTarget(
80-
name: "K1Tests",
81-
dependencies: [
82-
"K1",
83-
],
84-
resources: [
85-
.process("TestVectors/"),
86-
]
87-
),
88-
]
23+
name: "K1",
24+
platforms: [
25+
.iOS(.v13),
26+
.macOS(.v11),
27+
.tvOS(.v13),
28+
.watchOS(.v6),
29+
],
30+
products: [
31+
.library(
32+
name: "K1",
33+
targets: [
34+
"K1",
35+
]
36+
),
37+
],
38+
dependencies: [],
39+
targets: [
40+
// Target `libsecp256k1` https://github.com/bitcoin-core/secp256k1
41+
.target(
42+
name: "secp256k1",
43+
exclude: [
44+
"libsecp256k1/src/asm",
45+
"libsecp256k1/src/bench.c",
46+
"libsecp256k1/src/bench_ecmult.c",
47+
"libsecp256k1/src/bench_internal.c",
48+
"libsecp256k1/src/modules/extrakeys/tests_impl.h",
49+
"libsecp256k1/src/modules/schnorrsig/tests_impl.h",
50+
"libsecp256k1/src/precompute_ecmult.c",
51+
"libsecp256k1/src/precompute_ecmult_gen.c",
52+
"libsecp256k1/src/tests_exhaustive.c",
53+
"libsecp256k1/src/tests.c",
54+
"libsecp256k1/src/ctime_tests.c",
55+
56+
"libsecp256k1/examples/",
57+
58+
"libsecp256k1/autogen.sh",
59+
"libsecp256k1/CMakeLists.txt",
60+
"libsecp256k1/configure.ac",
61+
"libsecp256k1/COPYING",
62+
"libsecp256k1/libsecp256k1.pc.in",
63+
"libsecp256k1/Makefile.am",
64+
"libsecp256k1/README.md",
65+
"libsecp256k1/SECURITY.md",
66+
],
67+
cSettings: cSettings
68+
),
69+
.target(
70+
name: "K1",
71+
dependencies: [
72+
"secp256k1",
73+
],
74+
swiftSettings: [
75+
.define("CRYPTO_IN_SWIFTPM_FORCE_BUILD_API"),
76+
]
77+
),
78+
.testTarget(
79+
name: "K1Tests",
80+
dependencies: [
81+
"K1",
82+
],
83+
resources: [
84+
.process("TestVectors/"),
85+
]
86+
),
87+
]
8988
)
9089

9190
if development {
92-
for target in package.targets {
93-
target.swiftSettings = target.swiftSettings ?? []
94-
target.swiftSettings?.append(
95-
.unsafeFlags([
96-
"-Xfrontend", "-warn-concurrency",
97-
"-Xfrontend", "-enable-actor-data-race-checks",
98-
"-enable-library-evolution",
99-
])
100-
)
101-
}
91+
for target in package.targets {
92+
target.swiftSettings = target.swiftSettings ?? []
93+
target.swiftSettings?.append(
94+
.unsafeFlags([
95+
"-Xfrontend", "-warn-concurrency",
96+
"-Xfrontend", "-enable-actor-data-race-checks",
97+
"-enable-library-evolution",
98+
])
99+
)
100+
}
102101
}

Sources/K1/K1.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import Foundation
22

33
/// The Elliptic Curve `secp256k1`
44
public enum K1 {
5-
// The namespace for all structs and operations vendored by this library.
5+
// The namespace for all structs and operations vendored by this library.
66
}

0 commit comments

Comments
 (0)