Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI #1

Merged
merged 15 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .devcontainer/devcontainer-helper
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

set -euo pipefail

PROJECT_ROOT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
cd "$PROJECT_ROOT" || exit 1

print_help() {
cat <<- EOF
Usage: devcontainer-helper --make-singular <devcontainer-name>
--clean

The devcontainer/ci GitHub action does not support named devcontainers (i.e. ones located in subfolders of .devcontainer), so this script makes the selected devcontainer the singular devcontainer in the repo.
EOF
}

case "$1" in
"--help")
print_help
;;

"--make-singular")
DEVCONTAINER_NAME=$2
if [ -z "$DEVCONTAINER_NAME" ]; then
print_help
exit 1
fi

if [[ ! -d ".actual-devcontainer" ]]; then
mv .devcontainer .actual-devcontainer
else
rm -rf .devcontainer
fi

cp -R ".actual-devcontainer/$DEVCONTAINER_NAME" .devcontainer/
cp -R ".actual-devcontainer/$DEVCONTAINER_NAME" .devcontainer/
cp .actual-devcontainer/devcontainer-helper .devcontainer/
;;

"--clean")
if [[ ! -d ".actual-devcontainer" ]]; then
echo "No singular devcontainer to clean"
exit 1
fi

rm -rf .devcontainer
mv .actual-devcontainer .devcontainer
;;

*)
print_help
exit 1
;;
esac
101 changes: 101 additions & 0 deletions .github/workflows/Build and Test (SwiftPM).yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Build and Test

name: Build and Test (SwiftPM)
on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
build-and-test-macOS:
strategy:
matrix:
xcode-version:
- "16"
swift-configuration:
- "debug"
- "release"

runs-on: macos-15

name: Build and Test (macOS, ${{ matrix.swift-configuration }})

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode-version }}.app/Contents/Developer

- name: Build
run: |
swift build --configuration ${{ matrix.swift-configuration }}

- name: Build Tests
if: matrix.swift-configuration == 'debug'
run: |
swift build --build-tests --configuration ${{ matrix.swift-configuration }}

- name: Test
if: matrix.swift-configuration == 'debug'
run: |
swift test --skip-build

- name: Check that repository is clean
run:
git diff --exit-code

build-and-test-devcontainer:

strategy:
matrix:
devcontainer-name: ["default"]
swift-configuration: ["debug", "release"]

name: Build and Test (devcontainer/${{ matrix.devcontainer-name }}, ${{ matrix.swift-configuration }})

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Make devcontainer '${{ matrix.devcontainer-name }}' singular
run: .devcontainer/devcontainer-helper --make-singular ${{ matrix.devcontainer-name }}

- name: Initialize devcontainer
uses: devcontainers/[email protected]
with:
push: never
runCmd: |
echo "Devcontainer Initialized."

- name: Build
uses: devcontainers/[email protected]
with:
push: never
runCmd: |
swift build --configuration ${{ matrix.swift-configuration }}

- name: Build Tests
if: matrix.swift-configuration == 'debug'
uses: devcontainers/[email protected]
with:
push: never
runCmd: |
swift build --build-tests --configuration ${{ matrix.swift-configuration }}

- name: Test
uses: devcontainers/[email protected]
if: matrix.swift-configuration == 'debug'
with:
push: never
runCmd: |
swift test --skip-build

- name: Check that repository is clean
run:
.devcontainer/devcontainer-helper --clean
git diff --exit-code
67 changes: 67 additions & 0 deletions .github/workflows/Build and Test (Xcode).yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Build and Test

name: Build and Test (Xcode)
on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
build-and-test-xcode:
strategy:
matrix:
xcode-version:
- "16"
xcode-configuration:
- name: iOS Simulator
destination: "platform=iOS Simulator,name=iPhone 16"
sdk: "iphonesimulator"
- name: macOS
destination: "platform=macOS"
sdk: "macosx"
swift-configuration:
- "debug"
- "release"

runs-on: macos-15

name: Build and Test (${{ matrix.xcode-configuration.name }}, ${{ matrix.swift-configuration }})

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode-version }}.app/Contents/Developer

- name: Build
run: |
xcrun xcodebuild clean build \
-workspace Xcode/SwiftProjectTemplateApp.xcworkspace \
-scheme SwiftProjectTemplateApp \
-derivedDataPath ".build/Xcode.noindex/DerivedData" \
-configuration "${{ matrix.swift-configuration }}" \
-sdk "${{ matrix.xcode-configuration.sdk }}" \
-destination "${{ matrix.xcode-configuration.destination }}"

- name: Test
run: |
xcrun xcodebuild test \
-workspace Xcode/SwiftProjectTemplateApp.xcworkspace \
-scheme SwiftProjectTemplateAppUITests \
-derivedDataPath ".build/Xcode.noindex/DerivedData" \
-configuration "${{ matrix.swift-configuration }}" \
-sdk "${{ matrix.xcode-configuration.sdk }}" \
-destination "${{ matrix.xcode-configuration.destination }}"

- name: Upload Test Results
uses: actions/upload-artifact@v4
with:
name: Test Results (${{ matrix.xcode-configuration.name }}, ${{ matrix.swift-configuration }})
path: .build/Xcode.noindex/DerivedData/Logs/Test

- name: Check that repository is clean
run:
git diff --exit-code
41 changes: 41 additions & 0 deletions .github/workflows/Validate Formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Build and Test

name: Validate Formatting
on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
validate-formatting:
name: Validate Formatting

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Make devcontainer 'default' singular
run: .devcontainer/devcontainer-helper --make-singular default

- name: Initialize devcontainer
uses: devcontainers/[email protected]
with:
push: never
runCmd: |
echo "Devcontainer Initialized."

- name: Build
uses: devcontainers/[email protected]
with:
push: never
runCmd: |
swift format --recursive --in-place --parallel .

- name: Check that repository is clean
run:
.devcontainer/devcontainer-helper --clean
git diff --exit-code
4 changes: 0 additions & 4 deletions .github/workflows/specialize-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ jobs:
# Run specialization script (requires variables defined above)
./specialize-template.sh "$NEW_PROJECT_BUNDLE_ID_PREFIX" "$NEW_PROJECT_NAME"

rm -rf \
.github/workflows/specialize-template.yml \
specialize-template.sh

- name: Commit
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading