Skip to content

Commit

Permalink
Merge pull request #7 from tuist/continuous-integration
Browse files Browse the repository at this point in the history
feat: set up continuous integration
  • Loading branch information
pepicrft authored Aug 13, 2024
2 parents 63b0514 + 63bd53c commit 87a7ceb
Show file tree
Hide file tree
Showing 22 changed files with 254 additions and 15 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/apple-bundle-size-analyzer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Apple Bundle Size Analyzer

on:
push:
branches:
- main
pull_request: {}

env:
TUIST_CONFIG_TOKEN: ${{ secrets.TUIST_CONFIG_CLOUD_TOKEN }}

concurrency:
group: apple-bundle-size-analyzer-${{ github.head_ref }}
cancel-in-progress: true

jobs:
build:
name: "Release build on ${{ matrix.os }}"
timeout-minutes: 10
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
swift: ["5.10"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: SwiftyLab/setup-swift@latest
with:
swift-version: ${{ matrix.swift }}
- uses: jdx/mise-action@v2
if: runner.os == 'Linux' || runner.os == 'macOS'
with:
experimental: true
- name: Run
if: runner.os == 'Linux' || runner.os == 'macOS'
run: mise run build-spm
- name: Run
if: runner.os == 'Windows'
run: swift build --product AppleBundleSizeAnalyzer

build_tuist:
name: "Tuist build"
timeout-minutes: 10
runs-on: "macos-latest"
steps:
- uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -switch /Applications/Xcode_$(cat .xcode-version).app
- uses: jdx/mise-action@v2
with:
experimental: true
- name: Run
run: |
mise x -- tuist install
mise run build
test:
name: "Test on ${{ matrix.os }}"
timeout-minutes: 10
strategy:
matrix:
os: [macos-latest]
swift: ["5.10"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -switch /Applications/Xcode_$(cat .xcode-version).app
- uses: SwiftyLab/setup-swift@latest
with:
swift-version: ${{ matrix.swift }}
- uses: jdx/mise-action@v2
if: runner.os == 'Linux' || runner.os == 'macOS'
with:
experimental: true
- name: Run
if: runner.os == 'Linux' || runner.os == 'macOS'
run: mise run test-spm
- name: Run
if: runner.os == 'Windows'
run: swift test

test_tuist:
name: "Tuist test"
timeout-minutes: 10
runs-on: "macos-latest"
env:
TUIST_CONFIG_TOKEN: ${{ secrets.TUIST_CONFIG_CLOUD_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -switch /Applications/Xcode_$(cat .xcode-version).app
- uses: jdx/mise-action@v2
with:
experimental: true
- name: Run
run: |
mise x -- tuist install
mise run test
lint:
name: Lint
timeout-minutes: 10
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v2
with:
experimental: true
- name: Run
run: mise run lint
4 changes: 3 additions & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
tuist = "4.23.0"
"git-cliff" = "2.4.0"
"pnpm" = "9.7"
"nodejs" = "22.6.0"
"nodejs" = "22.6.0"
"swiftlint" = "0.54.0"
"swiftformat" = "0.52.10"
5 changes: 5 additions & 0 deletions .mise/tasks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# mise description="Build the project using Tuist"
set -euo pipefail

tuist build --path $MISE_PROJECT_ROOT
10 changes: 10 additions & 0 deletions .mise/tasks/build-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# mise description="Builds the project using Swift Package Manager in Linux"
set -euo pipefail

docker run --rm \
--volume "$MISE_PROJECT_ROOT:/package" \
--workdir "/package" \
swiftlang/swift:nightly-5.10-focal \
/bin/bash -c \
"swift build --product AppleBundleSizeAnalyzer --build-path ./.build/linux"
5 changes: 5 additions & 0 deletions .mise/tasks/build-spm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# mise description="Build the project using Swift Package Manager"
set -euo pipefail

swift build --product AppleBundleSizeAnalyzer --package-path $MISE_PROJECT_ROOT --configuration release
5 changes: 5 additions & 0 deletions .mise/tasks/cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# mise description="Cache the dependencies using Tuist"
set -euo pipefail

tuist cache --path $MISE_PROJECT_ROOT
6 changes: 6 additions & 0 deletions .mise/tasks/lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# mise description="Lint the project using SwiftLint and SwiftFormat"
set -euo pipefail

swiftformat $MISE_PROJECT_ROOT --lint
swiftlint lint --quiet --config $MISE_PROJECT_ROOT/.swiftlint.yml $MISE_PROJECT_ROOT/Sources
6 changes: 6 additions & 0 deletions .mise/tasks/lint-fix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# mise description="Lint the project using SwiftLint and SwiftFormat fixing the issues"
set -euo pipefail

swiftformat $MISE_PROJECT_ROOT
swiftlint lint --fix --quiet --config $MISE_PROJECT_ROOT/.swiftlint.yml $MISE_PROJECT_ROOT/Sources
5 changes: 5 additions & 0 deletions .mise/tasks/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# mise description="Test the project using Tuist"
set -euo pipefail

tuist test AppleBundleSizeAnalyzer --path $MISE_PROJECT_ROOT
10 changes: 10 additions & 0 deletions .mise/tasks/test-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# mise description="Builds the project using Swift Package Manager in Linux"
set -euo pipefail

docker run --rm \
--volume "$MISE_PROJECT_ROOT:/package" \
--workdir "/package" \
swiftlang/swift:nightly-5.10-focal \
/bin/bash -c \
"swift test --build-path ./.build/linux"
6 changes: 6 additions & 0 deletions .mise/tasks/test-spm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# mise description="Test the project using Swift Package Manager"

set -euo pipefail

swift test --package-path $MISE_PROJECT_ROOT
42 changes: 42 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# file options

--symlinks ignore
--disable hoistAwait
--disable hoistTry
--swiftversion 5.7

# format options

--allman false
--binarygrouping 4,8
--closingparen balanced
--commas always
--comments indent
--decimalgrouping 3,6
--elseposition same-line
--empty void
--exponentcase lowercase
--exponentgrouping disabled
--extensionacl on-declarations
--fractiongrouping disabled
--header strip
--hexgrouping 4,8
--hexliteralcase uppercase
--ifdef indent
--indent 4
--indentcase false
--importgrouping testable-bottom
--linebreaks lf
--octalgrouping 4,8
--operatorfunc spaced
--patternlet hoist
--ranges spaced
--self remove
--semicolons inline
--stripunusedargs always
--trimwhitespace always
--maxwidth 130
--wraparguments before-first
--wrapcollections before-first
--wrapconditions after-first
--wrapparameters before-first
24 changes: 24 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
disabled_rules:
- trailing_whitespace
- trailing_comma
- nesting
- cyclomatic_complexity
- file_length
- todo
- function_parameter_count
- opening_brace
- line_length
identifier_name:
min_length:
error: 1
warning: 1
max_length:
warning: 60
error: 80
inclusive_language:
override_allowed_terms:
- masterKey
type_name:
min_length:
error: 1
warning: 1
1 change: 1 addition & 0 deletions .xcode-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
15.4
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/tuist/Path.git", .upToNextMajor(from: "0.3.2")),
.package(url: "https://github.com/tuist/FileSystem.git", .upToNextMajor(from: "0.3.0")),
.package(url: "https://github.com/tuist/Command.git", .upToNextMajor(from: "0.6.3"))
.package(url: "https://github.com/tuist/Command.git", .upToNextMajor(from: "0.6.3")),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let project = Project(
dependencies: [
.external(name: "Path"),
.external(name: "FileSystem"),
.external(name: "Command")
.external(name: "Command"),
]
),
.target(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 2 additions & 2 deletions Tuist/Config.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ProjectDescription

let config = Config(
// Create an account with "tuist auth" and a project with "tuist project create"
// Create an account with "tuist auth" and a project with "tuist project create"
// then uncomment the section below and set the project full-handle.
// * Read more: https://docs.tuist.io/guides/quick-start/gather-insights
//
// fullHandle: "{account_handle}/{project_handle}",
fullHandle: "tuist/apple-bundle-size-analyzer"
)
6 changes: 3 additions & 3 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ export default defineConfig({
titleTemplate: ':title | Apple Bundle Analyzer | Tuist',
description: "Analyze Apple-generated bundles",
sitemap: {
hostname: 'https://apple-bundle-analyzer.tuist.io'
hostname: 'https://apple-bundle-size-analyzer.tuist.io'
},
themeConfig: {
logo: "/logo.png",
search: {
provider: "local",
},
nav: [
{ text: "Changelog", link: "https://github.com/tuist/AppleBundleAnalyzer/releases" }
{ text: "Changelog", link: "https://github.com/tuist/AppleBundleSizeAnalyzer/releases" }
],
editLink: {
pattern: "https://github.com/tuist/AppleBundleAnalyzer/edit/main/docs/:path",
pattern: "https://github.com/tuist/AppleBundleSizeAnalyzer/edit/main/docs/:path",
},
sidebar: [
{
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: "Apple Bundle Analyzer is a tool that helps you understand the size

Improving the size of a bundle generated by an Xcode project requires diving into the bundle and understanding what is taking up the space. Since this is a common need across many organizations, we open-sourced Apple Bundle Analyzer under MIT to make solving this problem easier and accessible to everyone.

`AppleBundleAnalyzer` powers some Tuist features and is actively maintained by the Tuist team.
`AppleBundleSizeAnalyzer` powers some Tuist features and is actively maintained by the Tuist team.

> [!TIP] TUIST ANALYZE
> If you don't plan to wrap Apple Bundle Analyzer in your own tool, you can use the command `tuist analyze size` to get a summary of the size of your bundles. The tool works with Xcode and Tuist projects.
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@tuist/apple-bundle-analyzer",
"name": "@tuist/apple-bundle-size-analyzer",
"devDependencies": {
"vitepress": "^1.3.2",
"wrangler": "^3.70.0"
Expand Down
10 changes: 5 additions & 5 deletions docs/quick-start/add-dependency.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ import PackageDescription
let package = Package(
name: "MyProject",
dependencies: [
.package(url: "https://github.com/tuist/AppleBundleAnalyzer.git", .upToNextMajor(from: "0.1.0")) // [!code ++]
.package(url: "https://github.com/tuist/AppleBundleSizeAnalyzer.git", .upToNextMajor(from: "0.1.0")) // [!code ++]
],
targets: [
.target(name: "MyProject",
dependencies: ["AppleBundleAnalyzer", .product(name: "AppleBundleAnalyzer", package: "AppleBundleAnalyzer")]), // [!code ++]
dependencies: ["AppleBundleSizeAnalyzer", .product(name: "AppleBundleSizeAnalyzer", package: "AppleBundleSizeAnalyzer")]), // [!code ++]
]
)
```

### Tuist

First, you'll have to add the `AppleBundleAnalyzer` package to your project's `Package.swift` file:
First, you'll have to add the `AppleBundleSizeAnalyzer` package to your project's `Package.swift` file:

```swift
import PackageDescription

let package = Package(
name: "MyProject",
dependencies: [
.package(url: "https://github.com/tuist/AppleBundleAnalyzer.git", .upToNextMajor(from: "0.1.0")) // [!code ++]
.package(url: "https://github.com/tuist/AppleBundleSizeAnalyzer.git", .upToNextMajor(from: "0.1.0")) // [!code ++]
]
)
```
Expand All @@ -61,7 +61,7 @@ let project = Project(
infoPlist: .default,
sources: ["Targets/App/Sources/**"],
dependencies: [
.external(name: "AppleBundleAnalyzer"), // [!code ++]
.external(name: "AppleBundleSizeAnalyzer"), // [!code ++]
]
),
]
Expand Down

0 comments on commit 87a7ceb

Please sign in to comment.