GitHub actions (#1744)

* Add GitHub actions

* Workflow typo

* Workflow typo

* Use GITHUB_TOKEN in build if available
This commit is contained in:
Matt Haggard 2020-12-11 17:04:30 -05:00 committed by GitHub
parent 7f690d35f0
commit 868b48a5af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

16
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,16 @@
on:
pull_request:
push:
jobs:
default:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: iffy/install-nim@v3
with:
version: stable
- run: nim c -d:ssl -r package_scanner.nim
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: node ./validate_json.js

View File

@ -54,12 +54,16 @@ proc canFetchNimbleRepository(name: string, urlJson: JsonNode): bool =
# nimble file in it
result = true
var url: string
var client = newHttpClient(timeout=100000)
defer: client.close()
if not urlJson.isNil:
url = urlJson.str
if url.startsWith("https://github.com"):
if existsEnv("GITHUB_TOKEN"):
client.headers = newHttpHeaders({"authorization": "Bearer " & getEnv("GITHUB_TOKEN")})
try:
discard getContent(url, timeout=10000)
discard client.getContent(url)
except HttpRequestError, TimeoutError:
echo "W: ", name, ": unable to fetch repo ", url, " ",
getCurrentExceptionMsg()