Skip to content

Commit cae91f2

Browse files
nekrichPaulTaykalo
andauthored
feat: testable DependenciesResolverRunner, YAML support, assets support (#30)
* chore: ignore SPM folders * chore: add BinaryDependenciesConfiguration (#9) * chore: add yams (#7) * chore: add config reader (#10) * fix: make sure that tests can be ran with `BinaryDependencyManager` target (#8) * fix: rename BinaryDependenciesManager to binary_dependencies_manager * fix: Make sure that target naming is CamelCase and tests works * fix: add Utils which is used from the Manager and the Runenr * fix: Add binary file to exclude * chpore: fix imports --------- Co-authored-by: Paul Taykalo <[email protected]> * chore: chore: add CLI and GitHub (#12) * chore: add Asset to Dependency (#13) * chore: add version (#11) * chore: public interface (#14) * chore: add BinaryDependenciesDownloader (#16) * chore: add GenericError (#17) * chore: add version to the BinaryDependenciesManager (#18) * chore: refactor resolve command (#15) * chore: refactor resolve command * chore: update resolve command * chore: add precondition * chore: add easter egg * chore: store dependenciesResolver * chore: fix unwrapping * chore: update file manager protocol (#20) * chore: remove unneded downloadSourceCode method (#26) * fix: resolve command (#23) * chore: update CleanCommand (#22) * chore: validate CLI run exit code (#24) * chore: Utils tests target (#25) * chore: add copyItem to FileManagerProtocol (#33) * chore: add ChecksumCalculatorProtocol (#32) * ci: add test workflow [refactor branch] (#28) * ci: add test workflow * fix(ci): linux build * chore: specify derived data for xcodebuild * chore: update Sources/BinaryDependencyManager/Utils/BinaryDependenciesConfigurationReader.swift * chore: refactor runner (#19) * chore: refactor DepeneciesResolverRunner * chore: Tests cleanup (#34) * Remove deduplication and simplify test setup * A bit refactored tests * fix: failing test with uuid neste temp dir * fix: unwrapping * chore: bump min target (#35) --------- Co-authored-by: Paul Taykalo <[email protected]> * chore: refactor download tests (#36) * fix: ci compilation (#38) * chore: refactor tests (#37) * chore: standartize file URLs and update tests (#39) --------- Co-authored-by: Paul Taykalo <[email protected]>
1 parent 25be31c commit cae91f2

File tree

47 files changed

+2476
-277
lines changed

Some content is hidden

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

47 files changed

+2476
-277
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
branches:
66
- main
7+
- chore/refactor
78

89
jobs:
910
test:
@@ -13,16 +14,16 @@ jobs:
1314
strategy:
1415
matrix:
1516
include:
16-
- os: macos-latest
17+
- os: macos-15
1718
build-system: swift
1819
swift-version: '6.1'
20+
xcode-version: '16.4'
1921
- os: ubuntu-latest
2022
build-system: swift
2123
swift-version: '6.1'
22-
# Will uncomment when target names are fixed.
23-
# - os: macos-15
24-
# build-system: xcodebuild
25-
# xcode-version: '16.4'
24+
- os: macos-15
25+
build-system: xcodebuild
26+
xcode-version: '16.4'
2627

2728
runs-on: ${{ matrix.os }}
2829

@@ -39,7 +40,9 @@ jobs:
3940
# swift-version: ${{ matrix.swift-version }}
4041

4142
- name: Setup Xcode
42-
if: matrix.build-system == 'xcodebuild'
43+
# Select Xcode for swift and xcodebuild.
44+
# We need 6.1 swift and setup-swift@v2 is broken.
45+
if: matrix.xcode-version != ''
4346
run: sudo xcode-select -s '/Applications/Xcode_${{ matrix.xcode-version }}.app'
4447

4548
- name: Cache Swift packages
@@ -71,6 +74,7 @@ jobs:
7174
xcodebuild \
7275
-scheme ${{ env.package_name }} \
7376
-destination 'platform=macOS' \
77+
-derivedDataPath DerivedData \
7478
-collect-test-diagnostics never \
7579
RUN_CLANG_STATIC_ANALYZER=NO \
7680
COMPILER_INDEX_STORE_ENABLE=NO \
@@ -82,6 +86,7 @@ jobs:
8286
xcodebuild \
8387
-scheme ${{ env.package_name }} \
8488
-destination 'platform=macOS' \
89+
-derivedDataPath DerivedData \
8590
-collect-test-diagnostics never \
8691
RUN_CLANG_STATIC_ANALYZER=NO \
8792
COMPILER_INDEX_STORE_ENABLE=NO \

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ DerivedData/
77
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
88
.netrc
99
*.zip
10+
Binary/binary-dependencies-manager
11+
/.swiftpm

Package.resolved

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,63 @@ import PackageDescription
66
let package = Package(
77
name: "binary-dependencies-manager",
88
platforms: [
9-
.macOS(.v11),
9+
.macOS(.v14),
1010
],
1111
products: [
1212
// Products define the executables and libraries a package produces, making them visible to other packages.
1313
.executable(
1414
name: "binary-dependencies-manager",
15-
targets: ["BinaryDependenciesManager"]
15+
targets: ["CommandLine"]
1616
),
1717
],
1818
dependencies: [
1919
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMajor(from: "1.5.1")),
2020
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMajor(from: "3.12.3")),
21+
.package(url: "https://github.com/jpsim/Yams.git", .upToNextMajor(from: "6.0.1")),
2122
],
2223

2324
targets: [
24-
// Targets are the basic building blocks of a package, defining a module or a test suite.
25-
// Targets can depend on other targets in this package and products from dependencies.
25+
2626
.executableTarget(
27-
name: "BinaryDependenciesManager",
27+
name: "CommandLine",
2828
dependencies: [
2929
.product(name: "ArgumentParser", package: "swift-argument-parser"),
30+
"BinaryDependencyManager",
31+
"Utils",
32+
]
33+
),
34+
35+
.target(
36+
name: "BinaryDependencyManager",
37+
dependencies: [
38+
"Utils",
39+
.product(name: "Yams", package: "Yams"),
40+
]
41+
),
42+
43+
.target(
44+
name: "Utils",
45+
dependencies: [
3046
.product(name: "Crypto", package: "swift-crypto"),
3147
]
3248
),
3349

3450
.testTarget(
35-
name: "DependenciesResolverTests",
36-
dependencies: ["BinaryDependenciesManager"]
51+
name: "BinaryDependencyManagerTests",
52+
dependencies: [
53+
.target(name: "BinaryDependencyManager"),
54+
]
3755
),
56+
57+
.testTarget(
58+
name: "UtilsTests",
59+
dependencies: [
60+
.target(name: "Utils"),
61+
]
62+
),
63+
],
64+
65+
swiftLanguageVersions: [
66+
.version("6")
3867
]
3968
)

README.md

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,42 +51,74 @@ Run the tool by specifying the required paths:
5151

5252
```sh
5353
./Binary/binary-dependencies-manager \
54-
--dependencies path/to/dependencies.json \
54+
--config path/to/.binary-dependencies.yaml \
5555
--cache path/to/cache \
5656
--output path/to/output
5757
```
5858

59-
- `--dependencies`: Path to your `dependencies.json` file (see format below)
59+
- `--config`, `-c`: Path to your `.binary-dependencies.yaml` file (see format below)
60+
- `--output`, `-o`: Directory where resolved dependencies will be extracted
6061
- `--cache`: Directory to use for caching downloads
61-
- `--output`: Directory where resolved dependencies will be extracted
6262

6363
## Example `dependencies.json`
6464
```json
6565
[
6666
{
6767
"repo": "MyOrg/MyLibrary",
6868
"tag": "1.2.3",
69-
"checksum": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
70-
"contents": "XCFrameworks/MyLibrary.xcframework",
71-
"pattern": "MyLibrary.xcframework.zip",
72-
"output": "MyLibrary"
69+
"assets": {
70+
"checksum": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
71+
"contents": "XCFrameworks/MyLibrary.xcframework",
72+
"pattern": "MyLibrary.xcframework.zip",
73+
"output": "MyLibrary"
74+
}
7375
},
7476
{
7577
"repo": "AnotherOrg/AnotherBinary",
7678
"tag": "0.9.0",
77-
"checksum": "d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2",
79+
"checksum": "7ab14dda40c47f9c4d1829b4c214898e4c61a2d3055c773169b7291d0f48cd0c",
7880
"pattern": "AnotherBinary.zip"
7981
}
8082
]
8183
```
8284

85+
```yaml
86+
---
87+
minimumVersion: 0.0.5
88+
outputDirectory: Dependencies
89+
cacheDirectory: .cache/binary-dependencies/
90+
dependencies:
91+
- repo: MyOrg/MyLibrary
92+
tag: 1.2.3
93+
assets:
94+
- contents: XCFrameworks/MyLibrary.xcframework
95+
checksum: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
96+
pattern: MyLibrary.xcframework.zip
97+
output: MyLibrary
98+
- repo: AnotherOrg/AnotherBinary
99+
tag: 0.9.0
100+
checksum: 7ab14dda40c47f9c4d1829b4c214898e4c61a2d3055c773169b7291d0f48cd0c
101+
pattern: AnotherBinary.zip
102+
```
103+
## Top level parameters
104+
- `minimumVersion` (optional): Minimum required binary-dependencies-manager version. Optional. Defaults to the current version.
105+
- `outputDirectory` (optional): Path to the output directory. Optional. Defaults to `Dependencies/Binary`.
106+
- `cacheDirectory` (optional): Path to the cache directory. Optional. Defaults to the `.cache/binary-dependencies`.
107+
108+
83109
## Dependency Parameters
84110
- `repo` (**required**): GitHub repository in the format `owner/repo` (e.g., `apple/swift-argument-parser`)
85111
- `tag` (**required**): Release tag to download (e.g., `1.0.0`)
112+
- `assets` (optional): A list of multiple binary assets to download from a given repo release.
113+
114+
> ℹ️ If no assets are provided you can specify asset parameters as a dependency parameters to download a single release artifact.
115+
116+
## Asset Parameters
86117
- `checksum` (**required**): SHA256 checksum of the zip archive for integrity verification
87118
- `contents` (optional): If provided, only the contents of this directory inside the archive will be extracted to the output directory
88119
- `pattern` (optional): Pattern to select a specific artifact from the release (useful if multiple assets are present)
89-
- `output` (optional): Subdirectory name to use for this dependency in the output directory (useful for organizing multiple artifacts)
120+
- `output` (optional): Subdirectory name to use for this dependency asset in the output directory (useful for organizing multiple artifacts)
121+
90122

91123
## Example Scenarios
92124
- **Download a single artifact:**

Sources/BinaryDependencyManager/Commands/CleanCommand.swift

Lines changed: 0 additions & 23 deletions
This file was deleted.

Sources/BinaryDependencyManager/Commands/ResolveCommand.swift

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)