swift
swift copied to clipboard
AppCenter CI support
Configured according to instructions: https://danger.systems/swift/guides/getting_started.html#setting-up-danger-to-run-on-your-ci
Package.swift
// swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "AppCenter",
dependencies: [
.package(url: "https://github.com/danger/swift.git", from: "2.0.0")
],
targets: [
// This is just an arbitrary Swift file in our app, that has
// no dependencies outside of Foundation, the dependencies section
// ensures that the library for Danger gets build also.
.target(name: "AppCenter", dependencies: ["Danger"], path: "AppCenter", sources: ["Test.swift"]),
]
)
Dangerfile.swift
import Danger
let danger = Danger()
let editedFiles = danger.git.modifiedFiles + danger.git.createdFiles
message("These files have changed: \(editedFiles.joined())")
appcenter-pre-build.sh
cd $APPCENTER_SOURCE_DIRECTORY
npm install -g danger
swift build
swift run danger-swift ci
AppCenter logs:
nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local"
Run `npm config delete prefix` or `nvm use --delete-prefix v6.17.1 --silent` to unset it.
/usr/local/lib/node_modules/danger/node_modules/ky/umd.js:59
returnValue = {...returnValue, [key]: value};
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/danger/node_modules/ky-universal/index.js:34:5)
##[error]/bin/bash failed with return code: 1
##[error]Bash failed with error: /bin/bash failed with return code: 1
Any help? Thank you!
I had a quick look at the logs and I saw that danger-js is failing. This might be related to the failure
2019-08-11T21:52:12.5208970Z nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local"
2019-08-11T21:52:12.5210500Z Run `npm config delete prefix` or `nvm use --delete-prefix v6.17.1 --silent` to unset it.
Added appcenter-post-clone.sh
npm i -D webpack@latest
npm install -g appcenter-cli
npm config delete prefix
AppCenter logs:
[7/8] Compiling Swift Module 'Runner' (6 sources)
[8/8] Linking ./.build/x86_64-apple-macosx/debug/danger-swift
/usr/local/lib/node_modules/danger/node_modules/ky/umd.js:59
returnValue = {...returnValue, [key]: value};
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/danger/node_modules/ky-universal/index.js:34:5)
##[error]/bin/bash failed with return code: 1
##[error]Bash failed with error: /bin/bash failed with return code: 1
##[section]Finishing: Pre Build Script
I can not see any clear reason, @orta do you have any idea?
Are you running on a really old version of node maybe?
I update it in appcenter-post-clone.sh
# please specify required Node.js version
NODE_VERSION=12.8.0
# workaround to override the v8 alias
npm config delete prefix
. ~/.bashrc
nvm install "$NODE_VERSION"
nvm alias default "$NODE_VERSION"
[command]/bin/bash /Users/vsts/agent/2.155.1/work/1/s/appcenter-post-clone.sh
Downloading and installing node v12.8.0...
Downloading https://nodejs.org/dist/v12.8.0/node-v12.8.0-darwin-x64.tar.xz...
#=#=#
##O#- #
####### 10.8%
################ 23.1%
############################ 39.9%
########################################## 58.8%
########################################################### 82.2%
######################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v12.8.0 (npm v6.10.2)
default -> 12.8.0 (-> v12.8.0 *)