Skip to content

Commit 1e1b0be

Browse files
committed
DevOps
1 parent 583ccdd commit 1e1b0be

File tree

6 files changed

+156
-0
lines changed

6 files changed

+156
-0
lines changed

.travis.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
language: csharp
2+
sudo: required
3+
dist: trusty
4+
addons:
5+
apt:
6+
packages:
7+
- gettext
8+
- libcurl4-openssl-dev
9+
- libicu-dev
10+
- libssl-dev
11+
- libunwind8
12+
- zlib1g
13+
env:
14+
global:
15+
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
16+
- DOTNET_CLI_TELEMETRY_OPTOUT: 1
17+
mono:
18+
- 4.0.5
19+
os:
20+
- linux
21+
- osx
22+
osx_image: xcode7.1
23+
branches:
24+
only:
25+
- master
26+
before_install:
27+
- if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi
28+
script:
29+
- ./build.sh --quiet verify

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
LeetCode
22
========
33

4+
[![Travis build status](https://img.shields.io/travis/codeyu/LeetCode.svg?label=travis-ci&branch=master&style=flat-square)](https://travis-ci.org/codeyu/LeetCode)
5+
[![Build status](https://ci.appveyor.com/api/projects/status/lek7s590ky46bym6?svg=true)](https://ci.appveyor.com/project/codeyu/leetcode)
46
### LeetCode Algorithms
57

68
(Notes: ":lock:" means you need to [subscribe to **premium membership**](https://leetcode.com/subscribe/) from Leetcode)

appveyor.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
init:
2+
- git config --global core.autocrlf true
3+
branches:
4+
only:
5+
- master
6+
build_script:
7+
- build.cmd verify
8+
clone_depth: 1
9+
test: off
10+
deploy: off

build.cmd

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@ECHO OFF
2+
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE"

build.ps1

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries)
4+
{
5+
while($true)
6+
{
7+
try
8+
{
9+
Invoke-WebRequest $url -OutFile $downloadLocation
10+
break
11+
}
12+
catch
13+
{
14+
$exceptionMessage = $_.Exception.Message
15+
Write-Host "Failed to download '$url': $exceptionMessage"
16+
if ($retries -gt 0) {
17+
$retries--
18+
Write-Host "Waiting 10 seconds before retrying. Retries left: $retries"
19+
Start-Sleep -Seconds 10
20+
21+
}
22+
else
23+
{
24+
$exception = $_.Exception
25+
throw $exception
26+
}
27+
}
28+
}
29+
}
30+
31+
cd $PSScriptRoot
32+
33+
$repoFolder = $PSScriptRoot
34+
$env:REPO_FOLDER = $repoFolder
35+
36+
$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
37+
if ($env:KOREBUILD_ZIP)
38+
{
39+
$koreBuildZip=$env:KOREBUILD_ZIP
40+
}
41+
42+
$buildFolder = ".build"
43+
$buildFile="$buildFolder\KoreBuild.ps1"
44+
45+
if (!(Test-Path $buildFolder)) {
46+
Write-Host "Downloading KoreBuild from $koreBuildZip"
47+
48+
$tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid()
49+
New-Item -Path "$tempFolder" -Type directory | Out-Null
50+
51+
$localZipFile="$tempFolder\korebuild.zip"
52+
53+
DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6
54+
55+
Add-Type -AssemblyName System.IO.Compression.FileSystem
56+
[System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder)
57+
58+
New-Item -Path "$buildFolder" -Type directory | Out-Null
59+
copy-item "$tempFolder\**\build\*" $buildFolder -Recurse
60+
61+
# Cleanup
62+
if (Test-Path $tempFolder) {
63+
Remove-Item -Recurse -Force $tempFolder
64+
}
65+
}
66+
67+
&"$buildFile" $args

build.sh

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
cd $repoFolder
4+
5+
koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
6+
if [ ! -z $KOREBUILD_ZIP ]; then
7+
koreBuildZip=$KOREBUILD_ZIP
8+
fi
9+
10+
buildFolder=".build"
11+
buildFile="$buildFolder/KoreBuild.sh"
12+
13+
if test ! -d $buildFolder; then
14+
echo "Downloading KoreBuild from $koreBuildZip"
15+
16+
tempFolder="/tmp/KoreBuild-$(uuidgen)"
17+
mkdir $tempFolder
18+
19+
localZipFile="$tempFolder/korebuild.zip"
20+
21+
retries=6
22+
until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null)
23+
do
24+
echo "Failed to download '$koreBuildZip'"
25+
if [ "$retries" -le 0 ]; then
26+
exit 1
27+
fi
28+
retries=$((retries - 1))
29+
echo "Waiting 10 seconds before retrying. Retries left: $retries"
30+
sleep 10s
31+
done
32+
33+
unzip -q -d $tempFolder $localZipFile
34+
35+
mkdir $buildFolder
36+
cp -r $tempFolder/**/build/** $buildFolder
37+
38+
chmod +x $buildFile
39+
40+
# Cleanup
41+
if test ! -d $tempFolder; then
42+
rm -rf $tempFolder
43+
fi
44+
fi
45+
46+
$buildFile -r $repoFolder "$@"

0 commit comments

Comments
 (0)