Skip to content

Commit ee23c93

Browse files
committed
Further work on the plugins/artifact bundles
1 parent 3f166c0 commit ee23c93

File tree

12 files changed

+1182
-251
lines changed

12 files changed

+1182
-251
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -94,45 +94,12 @@ jobs:
9494
.build/release/swift-dependency-audit
9595
retention-days: 7
9696

97-
test-cross-platform:
98-
name: Test Cross-Platform Docker Builds
99-
runs-on: ubuntu-latest
100-
if: github.event_name == 'push' || github.event_name == 'pull_request'
101-
strategy:
102-
fail-fast: false
103-
matrix:
104-
arch: [x86_64, aarch64]
105-
106-
steps:
107-
- name: Checkout code
108-
uses: actions/checkout@v4
109-
110-
- name: Set up Docker Buildx
111-
uses: docker/setup-buildx-action@v3
112-
113-
- name: Test Docker build for ${{ matrix.arch }}
114-
run: |
115-
# Test the same Docker build process used in releases
116-
docker run --rm \
117-
--platform linux/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }} \
118-
-v $PWD:/workspace \
119-
-w /workspace \
120-
swift:6.1 \
121-
bash -c "
122-
echo 'Testing Swift ${{ matrix.arch }} build...' && \
123-
swift --version && \
124-
swift build -c release --triple ${{ matrix.arch }}-unknown-linux-gnu && \
125-
echo 'Build successful for ${{ matrix.arch }}' && \
126-
ls -la .build/${{ matrix.arch }}-unknown-linux-gnu/release/swift-dependency-audit
127-
"
128-
129-
- name: Upload Docker build artifacts
130-
uses: actions/upload-artifact@v4
131-
with:
132-
name: docker-build-${{ matrix.arch }}
133-
path: |
134-
.build/${{ matrix.arch }}-unknown-linux-gnu/release/swift-dependency-audit
135-
retention-days: 7
97+
test-docker-builds:
98+
name: Test Docker Builds
99+
uses: ./.github/workflows/docker.yml
100+
with:
101+
upload_artifacts: true
102+
artifact_retention_days: 7
136103

137104
lint:
138105
name: Lint and Format Check
@@ -174,3 +141,58 @@ jobs:
174141
grep "warning:" build.log
175142
exit 1
176143
fi
144+
145+
validate-functionality:
146+
name: Validate Build Functionality
147+
runs-on: macos-15
148+
needs: [test, test-docker-builds]
149+
steps:
150+
- name: Checkout code
151+
uses: actions/checkout@v4
152+
153+
- name: Select Xcode version
154+
run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
155+
156+
- name: Cache Swift Package Manager
157+
uses: actions/cache@v4
158+
with:
159+
path: |
160+
.build
161+
~/.cache/org.swift.swiftpm
162+
key: ${{ runner.os }}-spm-validation-${{ hashFiles('Package.swift', 'Package.resolved') }}
163+
restore-keys: |
164+
${{ runner.os }}-spm-validation-
165+
${{ runner.os }}-spm-
166+
167+
- name: Build release binary
168+
run: swift build --configuration release
169+
170+
- name: Comprehensive CLI validation
171+
run: |
172+
echo "=== Testing CLI Help and Version ==="
173+
.build/release/swift-dependency-audit --help
174+
.build/release/swift-dependency-audit --version
175+
176+
echo "=== Testing Self-Analysis ==="
177+
.build/release/swift-dependency-audit . --verbose --exclude-tests
178+
179+
echo "=== Testing JSON Output ==="
180+
.build/release/swift-dependency-audit . --json --no-color > output.json
181+
cat output.json | python3 -m json.tool > /dev/null || (echo "❌ Invalid JSON output" && exit 1)
182+
echo "✅ JSON output is valid"
183+
184+
echo "=== Testing Xcode Output Format ==="
185+
.build/release/swift-dependency-audit . --output-format xcode --quiet
186+
187+
echo "=== Testing GitHub Actions Output Format ==="
188+
.build/release/swift-dependency-audit . --output-format github-actions --quiet
189+
190+
echo "=== Testing Custom Whitelist ==="
191+
.build/release/swift-dependency-audit . --whitelist "Foundation,SwiftUI,ArgumentParser" --verbose
192+
193+
- name: Plugin functionality validation
194+
run: |
195+
echo "=== Testing Plugin Integration ==="
196+
# Test that the plugin can be loaded
197+
swift package plugin --list | grep -q "DependencyAuditPlugin" || (echo "❌ Plugin not found" && exit 1)
198+
echo "✅ Plugin is properly registered"

.github/workflows/docker.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Docker Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
description: "Git ref to checkout"
8+
required: false
9+
default: ${{ github.ref }}
10+
type: string
11+
upload_artifacts:
12+
description: "Whether to upload artifacts"
13+
required: false
14+
default: false
15+
type: boolean
16+
artifact_retention_days:
17+
description: "How long to retain artifacts"
18+
required: false
19+
default: 7
20+
type: number
21+
outputs:
22+
artifact_name_x86_64:
23+
description: "Name of the x86_64 Linux artifact"
24+
value: ${{ jobs.build-linux.outputs.artifact_name_x86_64 }}
25+
artifact_name_aarch64:
26+
description: "Name of the aarch64 Linux artifact"
27+
value: ${{ jobs.build-linux.outputs.artifact_name_aarch64 }}
28+
29+
jobs:
30+
build-linux:
31+
runs-on: ubuntu-latest
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
arch: [x86_64, aarch64]
36+
outputs:
37+
artifact_name_x86_64: linux-x86_64-binary
38+
artifact_name_aarch64: linux-aarch64-binary
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v4
42+
with:
43+
ref: ${{ inputs.ref }}
44+
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v3
47+
48+
- name: Cache Docker layers
49+
uses: actions/cache@v4
50+
with:
51+
path: /tmp/.buildx-cache
52+
key: ${{ runner.os }}-buildx-${{ matrix.arch }}-${{ github.sha }}
53+
restore-keys: |
54+
${{ runner.os }}-buildx-${{ matrix.arch }}-
55+
56+
- name: Build Linux binary for ${{ matrix.arch }}
57+
run: |
58+
# Create build directory
59+
mkdir -p .build/${{ matrix.arch }}-unknown-linux-gnu/release
60+
61+
# Build for the specific architecture using Swift 6.1
62+
docker run --rm \
63+
--platform linux/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }} \
64+
-v $PWD:/workspace \
65+
-w /workspace \
66+
swift:6.1 \
67+
bash -c "
68+
echo 'Building Swift Dependency Audit for ${{ matrix.arch }}...' && \
69+
swift --version && \
70+
echo 'Resolving dependencies...' && \
71+
swift package resolve && \
72+
echo 'Building release binary...' && \
73+
swift build -c release --triple ${{ matrix.arch }}-unknown-linux-gnu -Xswiftc -Osize && \
74+
echo 'Build completed successfully for ${{ matrix.arch }}'
75+
"
76+
77+
- name: Strip binary for size optimization
78+
run: |
79+
if [ "${{ matrix.arch }}" = "aarch64" ]; then
80+
# Install cross-compilation tools for ARM64
81+
sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
82+
aarch64-linux-gnu-strip .build/${{ matrix.arch }}-unknown-linux-gnu/release/swift-dependency-audit
83+
else
84+
strip .build/${{ matrix.arch }}-unknown-linux-gnu/release/swift-dependency-audit
85+
fi
86+
87+
- name: Verify binary functionality
88+
if: matrix.arch == 'x86_64'
89+
run: |
90+
# Only test x86_64 binaries since we're running on x86_64
91+
echo "Testing binary functionality..."
92+
.build/${{ matrix.arch }}-unknown-linux-gnu/release/swift-dependency-audit --version
93+
.build/${{ matrix.arch }}-unknown-linux-gnu/release/swift-dependency-audit --help
94+
95+
- name: Display binary info
96+
run: |
97+
echo "Binary information for ${{ matrix.arch }}:"
98+
ls -la .build/${{ matrix.arch }}-unknown-linux-gnu/release/swift-dependency-audit
99+
file .build/${{ matrix.arch }}-unknown-linux-gnu/release/swift-dependency-audit
100+
du -h .build/${{ matrix.arch }}-unknown-linux-gnu/release/swift-dependency-audit
101+
102+
- name: Upload Linux binary artifacts
103+
if: inputs.upload_artifacts
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: linux-${{ matrix.arch }}-binary
107+
path: .build/${{ matrix.arch }}-unknown-linux-gnu/release/swift-dependency-audit
108+
retention-days: ${{ inputs.artifact_retention_days }}

0 commit comments

Comments
 (0)