Skip to content

Commit

Permalink
Web5 test vectors setup & integration (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
amika-sq authored Feb 1, 2024
1 parent ee22c4e commit 83a00c2
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 618 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,45 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

- name: Bootstrap
run: make bootstrap

- uses: swift-actions/setup-swift@v1
with:
swift-version: "5.9"

- name: Build
run: swift build

- name: Run tests
run: swift test

- uses: actions/upload-artifact@v3
with:
name: test-results
path: |
tests.xml
- name: Generate an access token to trigger downstream repo
uses: actions/create-github-app-token@2986852ad836768dfea7781f31828eb3e17990fa # v1.6.2
id: generate_token
if: github.ref == 'refs/heads/main'
with:
app-id: ${{ secrets.CICD_ROBOT_GITHUB_APP_ID }}
private-key: ${{ secrets.CICD_ROBOT_GITHUB_APP_PRIVATE_KEY }}
owner: TBD54566975
repositories: sdk-report-runner

- name: Trigger sdk-report-runner report build
if: github.ref == 'refs/heads/main'
run: |
curl -L \
-H "Authorization: Bearer ${APP_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/json" \
--fail \
--data '{"ref": "main"}' \
https://api.github.com/repos/TBD54566975/sdk-report-runner/actions/workflows/build-report.yaml/dispatches
env:
APP_TOKEN: ${{ steps.generate_token.outputs.token }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ Package.resolved
*.pyc
.docc-build
.vscode
Utilities/InstalledSwiftPMConfiguration/config.json
Utilities/InstalledSwiftPMConfiguration/config.json
tests.xml
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "web5-spec"]
path = Tests/Web5TestVectors/web5-spec
url = https://github.com/TBD54566975/web5-spec
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
bootstrap:
# Initialize submodules
git submodule update --init
# Initialize sparse checkout in the `web5-spec` submodule
git -C Tests/Web5TestVectors/web5-spec config core.sparseCheckout true
# Sparse checkout only the `test-vectors` directory from `web5-spec`
git -C Tests/Web5TestVectors/web5-spec sparse-checkout set test-vectors
# Update submodules so they sparse checkout takes effect
git submodule update
format:
swift format --in-place --recursive .

7 changes: 3 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let package = Package(
.package(url: "https://github.com/swift-extras/swift-extras-base64.git", from: "0.7.0"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump.git", from: "1.1.2"),
.package(url: "https://github.com/WeTransfer/Mocker.git", .upToNextMajor(from: "3.0.1")),
.package(url: "https://github.com/allegro/swift-junit.git", from: "2.1.0")
],
targets: [
.target(
Expand All @@ -37,13 +38,11 @@ let package = Package(
"Web5",
.product(name: "CustomDump", package: "swift-custom-dump"),
.product(name: "Mocker", package: "Mocker"),
.product(name: "SwiftTestReporter", package: "swift-junit"),
],
resources: [
.copy("Resources/crypto_ed25519"),
.copy("Resources/crypto_es256k"),
.copy("Resources/did_jwk"),
.copy("Resources/did_web"),
.copy("Resources/did"),
.copy("web5-spec/test-vectors"),
]
),
]
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# web5-swift

WIP!
WIP!

# Prerequisites

## Cloning

After cloning this repository, run:
```
make bootstrap
```

This will configure the repository's submodules properly, and ensure you're all set to go!
20 changes: 20 additions & 0 deletions Tests/Web5TestVectors/AAA_JUnitReportInitializer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import SwiftTestReporter
import XCTest

@testable import Web5

/// This test class must be executed first. The `AAA_` prefix helps ensure this,
/// but it is not guaranteed. Make sure that this is alphabetically the first test
/// class in the `Web5TestVectors` target!
///
/// This is necessary to allow `SwiftTestReporterInit` to create a `tests.xml`.
/// See https://github.com/allegro/swift-junit/issues/12#issuecomment-725264315
class AAA_JUnitReportInitializer: XCTestCase {
override class func setUp() {
_ = TestObserver()
super.setUp()
}

// No-op test function to be interpreted as a test case
func testInit() {}
}
78 changes: 0 additions & 78 deletions Tests/Web5TestVectors/Resources/crypto_ed25519/sign.json

This file was deleted.

125 changes: 0 additions & 125 deletions Tests/Web5TestVectors/Resources/crypto_ed25519/verify.json

This file was deleted.

Loading

0 comments on commit 83a00c2

Please sign in to comment.