Skip to content

Commit 4810d76

Browse files
authored
Merge pull request #184 from lrytz/commit-status
AppVeyor status
2 parents dc01582 + a8aa920 commit 4810d76

File tree

5 files changed

+55
-23
lines changed

5 files changed

+55
-23
lines changed

.travis.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,17 @@ env:
4141

4242
script:
4343
- source scripts/common
44-
- if [[ "$scala_sha" != "" ]]; then postCommitStatus "pending"; fi
44+
- postCommitStatus "pending"
4545
- admin/build.sh
4646

4747
after_script:
4848
- |
49-
if [[ "$scala_sha" != "" ]]; then
50-
if [[ "$TRAVIS_TEST_RESULT" == "0" ]]; then
51-
local state="success"
52-
else
53-
local state="failure"
54-
fi
55-
postCommitStatus $state
49+
if [[ "$TRAVIS_TEST_RESULT" == "0" ]]; then
50+
local state="success"
51+
else
52+
local state="failure"
5653
fi
54+
postCommitStatus $state
5755
5856
cache:
5957
directories:

admin/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ function setupSSH() {
3636
}
3737

3838
function triggerMsiRelease() {
39-
local jsonTemplate='{ "accountName": "scala", "projectSlug": "scala-dist", "branch": "%s", "commitId": "%s", "environmentVariables": { "mode": "%s", "version": "%s" } }'
40-
local json=$(printf "$jsonTemplate" "$TRAVIS_BRANCH" "$TRAVIS_COMMIT" "$mode" "$version")
39+
local jsonTemplate='{ "accountName": "scala", "projectSlug": "scala-dist", "branch": "%s", "commitId": "%s", "environmentVariables": { "mode": "%s", "version": "%s", "scala_sha": "%s" } }'
40+
local json=$(printf "$jsonTemplate" "$TRAVIS_BRANCH" "$TRAVIS_COMMIT" "$mode" "$version" "$scala_sha")
4141

4242
local curlStatus=$(curl \
4343
-s -o /dev/null -w "%{http_code}" \

appveyor.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,24 @@ environment:
1414
secure: X1Ix1soRBDMtfbi8IFNPOggDP2XquhW+uKcJ+XC0kiM=
1515
AWS_SECRET_ACCESS_KEY:
1616
secure: woXwpM2+P3uZ1+LFM+SbJEKLfi7Kax5PvqJSN62nn1PQrJgEzVUAIoRGoXBx6X72
17+
GITHUB_OAUTH_TOKEN:
18+
secure: oji2LTrdEhQhJQOoRU3TFuCmCb92XD1BJKW7uw0/XJdEFkOrb4lKbHjPGeuOY6/5
1719

1820
install:
1921
- cmd: choco install sbt -ia "INSTALLDIR=""C:\sbt"""
2022
- cmd: SET PATH=C:\sbt\bin;%JAVA_HOME%\bin;%PATH%
2123

2224
build_script:
23-
- ps: .\admin\build.ps1
25+
- ps: >-
26+
. .\scripts\common.ps1
27+
postCommitStatus "pending"
28+
.\admin\build.ps1
29+
30+
on_success:
31+
- ps: postCommitStatus "pending"
32+
33+
on_failure:
34+
- ps: postCommitStatus "failure"
2435

2536
cache:
2637
- C:\sbt\

scripts/common

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@ function travis_fold_end() {
1212
# Params:
1313
# - state: pending / success / failed / error
1414
function postCommitStatus() {
15-
local jsonTemplate='{ "state": "%s", "target_url": "%s", "description": "%s", "context": "%s"}'
16-
local json=$(printf "$jsonTemplate" "$1" "https://travis-ci.org/scala/scala-dist/builds/$TRAVIS_BUILD_ID" "$1" "travis/scala-dist/$version/$mode")
15+
if [[ "$scala_sha" != "" ]]; then
16+
local jsonTemplate='{ "state": "%s", "target_url": "%s", "description": "%s", "context": "%s"}'
17+
local json=$(printf "$jsonTemplate" "$1" "https://travis-ci.org/scala/scala-dist/builds/$TRAVIS_BUILD_ID" "$1" "travis/scala-dist/$version/$mode")
1718

18-
local curlStatus=$(curl \
19-
-s -o /dev/null -w "%{http_code}" \
20-
-H "Accept: application/vnd.github.v3+json" \
21-
-H "Authorization: token $GITHUB_OAUTH_TOKEN" \
22-
-d "$json" \
23-
https://api.github.com/repos/scala/scala/statuses/$scala_sha)
19+
local curlStatus=$(curl \
20+
-s -o /dev/null -w "%{http_code}" \
21+
-H "Accept: application/vnd.github.v3+json" \
22+
-H "Authorization: token $GITHUB_OAUTH_TOKEN" \
23+
-d "$json" \
24+
https://api.github.com/repos/scala/scala/statuses/$scala_sha)
2425

25-
[[ "$curlStatus" == "201" ]] || {
26-
echo "Failed to publish GitHub commit status"
27-
exit 1
28-
}
26+
[[ "$curlStatus" == "201" ]] || {
27+
echo "Failed to publish GitHub commit status"
28+
exit 1
29+
}
30+
fi
2931
}

scripts/common.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Function postCommitStatus($state) {
2+
if ($env:scala_sha -ne '') {
3+
$jsonTemplate = '{{ "state": "{0}", "target_url": "{1}", "description": "{2}", "context": "{3}" }}'
4+
$json = "$jsonTemplate" -f "$state", "https://ci.appveyor.com/project/scala/scala-dist/build/$env:APPVEYOR_BUILD_ID", "$state", "appveyor/scala-dist/$env:version/$env:mode"
5+
6+
# https://stackoverflow.com/questions/41618766/powershell-invoke-webrequest-fails-with-ssl-tls-secure-channel
7+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
8+
9+
$respone = Invoke-WebRequest `
10+
"https://api.github.com/repos/scala/scala/statuses/$env:scala_sha" `
11+
-Method 'POST' `
12+
-Body "$json" `
13+
-Headers @{"Accept"="application/vnd.github.v3+json"; "Authorization"="token $env:GITHUB_OAUTH_TOKEN"} `
14+
-UseBasicParsing
15+
16+
if ($respone.StatusCode -ne 201) {
17+
echo "Failed to publish GitHub commit status"
18+
Exit 1
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)