Skip to content

Commit

Permalink
🌱
Browse files Browse the repository at this point in the history
Co-authored-by: Stephen Celis <[email protected]>
  • Loading branch information
2 people authored and mbrandonw committed May 2, 2022
0 parents commit 2ef446c
Show file tree
Hide file tree
Showing 15 changed files with 1,078 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- '*'
workflow_dispatch:

jobs:
macos_tests:
runs-on: macos-12
strategy:
matrix:
xcode:
- "13.2.1" # Swift 5.5
command:
- test
steps:
- uses: actions/checkout@v2
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: System
run: system_profiler SPHardwareDataType
- name: Run ${{ matrix.command }}
run: make ${{ matrix.command }}

ubuntu_tests:
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04]

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

steps:
- uses: actions/checkout@v2
- name: Build
run: swift build
- name: Run tests
run: swift test
112 changes: 112 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Build and deploy DocC to GitHub pages. Based off of @karwa's work here:
# https://github.com/karwa/swift-url/blob/main/.github/workflows/docs.yml
name: Documentation

on:
release:
types:
- published
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Package
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Download Swift 5.5.1
run: wget -q https://download.swift.org/swift-5.5.1-release/ubuntu2004/swift-5.5.1-RELEASE/swift-5.5.1-RELEASE-ubuntu20.04.tar.gz
- name: Extract Swift 5.5.1
run: tar xzf swift-5.5.1-RELEASE-ubuntu20.04.tar.gz
- name: Add Swift toolchain to PATH
run: |
echo "$GITHUB_WORKSPACE/swift-5.5.1-RELEASE-ubuntu20.04/usr/bin" >> $GITHUB_PATH
- name: Checkout swift-docc
uses: actions/checkout@v2
with:
repository: apple/swift-docc
ref: main
path: swift-docc
- name: Cache DocC
id: cache-docc
uses: actions/cache@v2
with:
key: swift-url-docc-build
path: swift-docc/.build
- name: Build swift-docc
if: ${{ !steps.cache-docc.outputs.cache-hit }}
run: |
cd swift-docc; swift build --product docc -c release; cd ..
- name: Checkout swift-docc-render
uses: actions/checkout@v2
with:
repository: apple/swift-docc-render
ref: main
path: swift-docc-render
- name: Build swift-docc-render
run: |
cd swift-docc-render; npm install && npm run build; cd ..
- name: Checkout gh-pages Branch
uses: actions/checkout@v2
with:
ref: gh-pages
path: docs-out

- name: Build documentation
run: >
rm -rf docs-out/.git;
rm -rf docs-out/main;
for tag in $(echo "main"; git tag);
do
echo "⏳ Generating documentation for "$tag" release.";
if [ -d "docs-out/$tag" ]
then
echo "✅ Documentation for "$tag" already exists.";
else
git checkout "$tag";
mkdir -p Sources/VaporRouting/Documentation.docc;
export DOCC_HTML_DIR="$(pwd)/swift-docc-render/dist";
rm -rf .build/symbol-graphs;
mkdir -p .build/symbol-graphs;
swift build \
--target VaporRouting \
-Xswiftc \
-emit-symbol-graph \
-Xswiftc \
-emit-symbol-graph-dir \
-Xswiftc \
.build/symbol-graphs \
&& swift-docc/.build/release/docc convert Sources/VaporRouting/Documentation.docc \
--fallback-display-name VaporRouting \
--fallback-bundle-identifier co.pointfree.VaporRouting \
--fallback-bundle-version 0.0.0 \
--additional-symbol-graph-dir \
.build/symbol-graphs \
--transform-for-static-hosting \
--hosting-base-path /swift-vapor-routing/"$tag" \
--output-path docs-out/"$tag" \
&& echo "✅ Documentation generated for "$tag" release." \
|| echo "⚠️ Documentation skipped for "$tag".";
fi;
done
- name: Fix permissions
run: 'sudo chown --recursive $USER docs-out'
- name: Publish documentation to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: docs-out
single-commit: true
27 changes: 27 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Format

on:
push:
branches:
- main

jobs:
swift_format:
name: swift-format
runs-on: macOS-11
steps:
- uses: actions/checkout@v2
- name: Xcode Select
run: sudo xcode-select -s /Applications/Xcode_13.0.app
- name: Tap
run: brew tap pointfreeco/formulae
- name: Install
run: brew install Formulae/[email protected]
- name: Format
run: make format
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Run swift-format
branch: 'main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Point-Free

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
PLATFORM_MACOS = macOS

default: test

test:
xcodebuild test \
-scheme vapor-routing \
-destination platform="$(PLATFORM_MACOS)"

test-linux:
docker run \
--rm \
-v "$(PWD):$(PWD)" \
-w "$(PWD)" \
swift:5.3 \
bash -c 'make test-swift'

test-swift:
swift test \
--enable-test-discovery \
--parallel

format:
swift format --in-place --recursive \
./Package.swift ./Sources ./Tests
find . -type f -name '*.md' -print0 | xargs -0 perl -pi -e 's/ +$$//'

.PHONY: format test
Loading

0 comments on commit 2ef446c

Please sign in to comment.