Skip to content

Bump setup-swift from 1.26.0 to 2.0.0 #450

Bump setup-swift from 1.26.0 to 2.0.0

Bump setup-swift from 1.26.0 to 2.0.0 #450

Workflow file for this run

name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
get_os:
name: Determine supported OS
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check and output correct matrix
id: output_data
run: |
macos='macOS-latest'
if [ -e .github/macos_version.txt ]
then
macos=$(cat ./.github/macos_version.txt)
fi
if [ -e .github/macos_only ]
then
echo "os_matrix=['$macos']" >> $GITHUB_OUTPUT
echo "coverage_os=$macos" >> $GITHUB_OUTPUT
else
echo "os_matrix=['$macos', 'ubuntu-latest']" >> $GITHUB_OUTPUT
echo "coverage_os=ubuntu-latest" >> $GITHUB_OUTPUT
fi
outputs:
os_matrix: ${{ steps.output_data.outputs.os_matrix }}
coverage_os: ${{ steps.output_data.outputs.coverage_os }}
test:
name: Tests
needs: get_os
strategy:
matrix:
os: ${{fromJson(needs.get_os.outputs.os_matrix)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Swift
uses: swift-actions/setup-swift@v2.0.0
- name: Run tests
run: swift test --enable-code-coverage -Xswiftc -warnings-as-errors
- name: Save PR number
if: ${{ matrix.os == needs.get_os.outputs.coverage_os }}
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
- name: Generate test coverage report
if: ${{ matrix.os == needs.get_os.outputs.coverage_os }}
uses: maxep/spm-lcov-action@0.3.1
with:
output-file: ./pr/lcov.info
- name: Upload Coverage Information for Comment
if: ${{ matrix.os == needs.get_os.outputs.coverage_os }}
uses: actions/upload-artifact@v4
with:
name: pr
path: pr/
- name: 'Read minimum coverage'
if: ${{ matrix.os == needs.get_os.outputs.coverage_os }}
run: echo "minimum_coverage=$(cat ./.github/minimum_coverage.txt)" >> $GITHUB_ENV
- name: Enforce test coverage threshhold
if: ${{ matrix.os == needs.get_os.outputs.coverage_os }}
uses: VeryGoodOpenSource/very_good_coverage@v3.0.0
with:
path: ./pr/lcov.info
min_coverage: ${{ env.minimum_coverage }}
swiftlint:
name: SwiftLint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Swift
uses: swift-actions/setup-swift@v2.0.0
- name: Install SwiftLint
run: |
curl -L https://github.com/realm/SwiftLint/releases/download/0.54.0/swiftlint_linux.zip -o swiftlint.zip
unzip swiftlint.zip -d swiftlint
./swiftlint/swiftlint --version
- name: Run SwiftLint
run: ./swiftlint/swiftlint --strict --reporter github-actions-logging