Skip to content

Commit

Permalink
fix: order for XCLocalSwiftPackageReference and `XCRemoteSwiftPacka…
Browse files Browse the repository at this point in the history
…geReference` (#855)

* Flip the order of `XCLocalSwiftPackageReference` and `XCRemoteSwiftPackageReference`

* Add tasks to run tests and build the package in Linux from a macOS environment using Podman

* Install Swift in the Linux environments

* Remove Tests/LinuxMain.swift

* Build and test in a virtualized Linux container from the macOS environment

* Set up Docker

* Install Podman

* Initialize the machine before starting it

* Run from ubuntu-latest

---------

Co-authored-by: Pedro <pedro@pepicrft.me>
  • Loading branch information
kimdv and pepicrft authored Sep 27, 2024
1 parent 46fe156 commit 22eea63
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 79 deletions.
28 changes: 10 additions & 18 deletions .github/workflows/xcodeproj.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,34 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- uses: jdx/mise-action@v2
- name: Build
run: swift build -c release
run: mise run build
build-linux:
name: Build (Linux)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: jdx/mise-action@v2
- name: Build
run: swift build -c release
run: mise run build-linux
test:
name: Test (macOS / Xcode)
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- uses: jdx/mise-action@v2
- name: Run tests
run: swift test --enable-code-coverage
- name: Send test coverage report
run: bash <(curl -s https://codecov.io/bash)
run: mise run test

test-linux:
name: Test (Linux)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set Git config
run: |
git config --global user.email "xcodeproj@tuist.io"
git config --global user.name "xcodeproj"
git config --global init.defaultBranch main
- name: Build and run tests
run: swift test --enable-test-discovery
- uses: jdx/mise-action@v2
- name: Test
run: mise run test-linux

lint:
name: Lint
Expand Down
1 change: 1 addition & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
swiftformat = "0.54.3"
tuist = "4.27.0"
swiftlint = "0.55.1"
swift="5.10.1"
"git-cliff" = "2.4.0"
4 changes: 4 additions & 0 deletions .mise/tasks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
# mise description="Build the package in the host"

swift build --package-path $MISE_PROJECT_ROOT --configuration debug
16 changes: 16 additions & 0 deletions .mise/tasks/build-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# mise description="Build on Linux"

CONTAINER_RUNTIME=$(command -v podman || command -v docker)

if [ -z "$CONTAINER_RUNTIME" ]; then
echo "Neither podman nor docker is available. Please install one to proceed."
exit 1
fi

$CONTAINER_RUNTIME run --rm --interactive --tty --volume "$(pwd):/package" --workdir "/package" swift:5.10.1 bash -c "
git config --global user.email 'xcodeproj@tuist.io' &&
git config --global user.name 'xcodeproj' &&
git config --global init.defaultBranch main &&
swift build --configuration release
"
4 changes: 4 additions & 0 deletions .mise/tasks/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
# mise description="Run tests in the host"

swift test --package-path $MISE_PROJECT_ROOT
16 changes: 16 additions & 0 deletions .mise/tasks/test-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# mise description="Run tests on Linux"

CONTAINER_RUNTIME=$(command -v podman || command -v docker)

if [ -z "$CONTAINER_RUNTIME" ]; then
echo "Neither podman nor docker is available. Please install one to proceed."
exit 1
fi

$CONTAINER_RUNTIME run --rm --interactive --tty --volume "$(pwd):/package" --workdir "/package" swift:5.10.1 bash -c "
git config --global user.email 'xcodeproj@tuist.io' &&
git config --global user.name 'xcodeproj' &&
git config --global init.defaultBranch main &&
swift test
"
96 changes: 47 additions & 49 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,52 +1,50 @@
{
"object": {
"pins": [
{
"package": "AEXML",
"repositoryURL": "https://github.com/tadija/AEXML.git",
"state": {
"branch": null,
"revision": "38f7d00b23ecd891e1ee656fa6aeebd6ba04ecc3",
"version": "4.6.1"
}
},
{
"package": "PathKit",
"repositoryURL": "https://github.com/kylef/PathKit.git",
"state": {
"branch": null,
"revision": "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
"version": "1.0.1"
}
},
{
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version": "0.10.1"
}
},
{
"package": "SwiftDocCPlugin",
"repositoryURL": "https://github.com/apple/swift-docc-plugin",
"state": {
"branch": null,
"revision": "26ac5758409154cc448d7ab82389c520fa8a8247",
"version": "1.3.0"
}
},
{
"package": "SymbolKit",
"repositoryURL": "https://github.com/apple/swift-docc-symbolkit",
"state": {
"branch": null,
"revision": "b45d1f2ed151d057b54504d653e0da5552844e34",
"version": "1.0.0"
}
"pins" : [
{
"identity" : "aexml",
"kind" : "remoteSourceControl",
"location" : "https://github.com/tadija/AEXML.git",
"state" : {
"revision" : "38f7d00b23ecd891e1ee656fa6aeebd6ba04ecc3",
"version" : "4.6.1"
}
]
},
"version": 1
},
{
"identity" : "pathkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kylef/PathKit.git",
"state" : {
"revision" : "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
"version" : "1.0.1"
}
},
{
"identity" : "spectre",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kylef/Spectre.git",
"state" : {
"revision" : "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version" : "0.10.1"
}
},
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-plugin",
"state" : {
"revision" : "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64",
"version" : "1.4.3"
}
},
{
"identity" : "swift-docc-symbolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-docc-symbolkit",
"state" : {
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
"version" : "1.0.0"
}
}
],
"version" : 2
}
8 changes: 4 additions & 4 deletions Sources/XcodeProj/Objects/Project/PBXProjEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@ final class PBXProjEncoder {
outputSettings: outputSettings,
stateHolder: &stateHolder,
to: &output)
try write(section: "XCRemoteSwiftPackageReference",
try write(section: "XCLocalSwiftPackageReference",
proj: proj,
objects: proj.objects.remoteSwiftPackageReferences,
objects: proj.objects.localSwiftPackageReferences,
outputSettings: outputSettings,
stateHolder: &stateHolder,
to: &output)
try write(section: "XCLocalSwiftPackageReference",
try write(section: "XCRemoteSwiftPackageReference",
proj: proj,
objects: proj.objects.localSwiftPackageReferences,
objects: proj.objects.remoteSwiftPackageReferences,
outputSettings: outputSettings,
stateHolder: &stateHolder,
to: &output)
Expand Down
8 changes: 0 additions & 8 deletions Tests/LinuxMain.swift

This file was deleted.

0 comments on commit 22eea63

Please sign in to comment.