From 5e85356a1c10cdb0b6c552cf62a4f7e795f923b7 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Wed, 10 Jun 2020 18:26:43 +0100 Subject: [PATCH] Migrate CI to GitHub Actions, test on Linux --- .github/workflows/danger.yml | 22 ++++++++++++++++++++++ .github/workflows/swift.yml | 30 ++++++++++++++++++++++++++++++ .vscode/tasks.json | 17 +++++++++++++++++ Package.swift | 2 +- Tests/LinuxMain.swift | 7 ------- azure-pipelines.yml | 19 ------------------- codecov.sh | 5 ++--- lint.sh | 9 --------- test.sh | 5 ++++- 9 files changed, 76 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/danger.yml create mode 100644 .github/workflows/swift.yml create mode 100644 .vscode/tasks.json delete mode 100644 Tests/LinuxMain.swift delete mode 100644 azure-pipelines.yml delete mode 100755 lint.sh diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml new file mode 100644 index 00000000..98dd2584 --- /dev/null +++ b/.github/workflows/danger.yml @@ -0,0 +1,22 @@ +# This is a basic workflow to help you get started with Actions + +name: Danger + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + pull_request: + branches: [master] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + danger-lint: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + + - name: Danger Swift + uses: maxdesiatov/danger-swift@swiftlint-docker + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml new file mode 100644 index 00000000..60f24fc1 --- /dev/null +++ b/.github/workflows/swift.yml @@ -0,0 +1,30 @@ +name: Build and test + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + macos_build: + runs-on: macos-10.15 + + steps: + - uses: actions/checkout@v2 + - name: Build + shell: bash + run: | + set -x + ./test.sh + ./codecov.sh + + linux_build: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + - name: Test on Ubuntu with Swift 5.2 + uses: Didstopia/SwiftAction@v1.0.2 + with: + swift-action: test --enable-test-discovery diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..a69b2d14 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "swift build", + "type": "shell", + "command": "swift build" + }, + { + "label": "swift test", + "type": "shell", + "command": "swift test" + } + ] +} diff --git a/Package.swift b/Package.swift index 615289ac..3a7efcbc 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.1 +// swift-tools-version:5.2 // The swift-tools-version declares the minimum version of Swift required to // build this package. diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100644 index 91cb704a..00000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,7 +0,0 @@ -import XCTest - -import TokamakTests - -var tests = [XCTestCaseEntry]() -tests += TokamakTests.allTests() -XCTMain(tests) diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index dacce40b..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,19 +0,0 @@ -trigger: - - master - -jobs: - - job: lint - pool: - vmImage: "macOS-10.15" - steps: - - bash: ./lint.sh - - - job: test - pool: - vmImage: "macOS-10.15" - steps: - - bash: ./test.sh - - bash: ./codecov.sh - env: - CODECOV_TOKEN: $(codecovToken) - condition: succeeded() diff --git a/codecov.sh b/codecov.sh index b1347c51..bfbc950b 100755 --- a/codecov.sh +++ b/codecov.sh @@ -1,6 +1,5 @@ #!/bin/bash -set -e -set -o pipefail +set -ex -bash <(curl -s https://codecov.io/bash) \ No newline at end of file +bash <(curl -s https://codecov.io/bash) diff --git a/lint.sh b/lint.sh deleted file mode 100755 index 4c55c207..00000000 --- a/lint.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -ex - -brew update -brew install swiftformat swiftlint - -swiftformat --lint --verbose . -swiftlint diff --git a/test.sh b/test.sh index b7846191..7230c0ce 100755 --- a/test.sh +++ b/test.sh @@ -2,4 +2,7 @@ set -ex -swift test +swift test --enable-code-coverage +xcrun llvm-cov show \ + .build/debug/TokamakPackageTests.xctest/Contents/MacOS/TokamakPackageTests \ + -instr-profile=.build/debug/codecov/default.profdata > coverage.txt