Skip to content

Commit e1b531e

Browse files
authored
Use Github Actions to run CI (#46)
* use Github Actions to run CI * move travis and appveyor jobs to backup dir * Docs update
1 parent 2694f3c commit e1b531e

File tree

7 files changed

+138
-5
lines changed

7 files changed

+138
-5
lines changed
File renamed without changes.
File renamed without changes.

.github/workflows/BuildDylib.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build Dylib
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
# tags: '*'
8+
release:
9+
types:
10+
- created
11+
pull_request:
12+
types: [opened, synchronize, reopened]
13+
14+
jobs:
15+
build:
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
julia-version: [1.2]
20+
julia-arch: [x64]
21+
os: [ubuntu-latest]
22+
steps:
23+
- uses: actions/[email protected]
24+
- name: Set up Julia
25+
uses: julia-actions/setup-julia@latest
26+
with:
27+
version: ${{ matrix.julia-version }}
28+
- name: Install dependencies
29+
run: julia -e 'using Pkg; Pkg.add("BinaryProvider"); Pkg.add("BinaryBuilder");'
30+
- name: Build
31+
env:
32+
BINARYBUILDER_DOWNLOADS_CACHE: downloads
33+
BINARYBUILDER_AUTOMATIC_APPLE: true
34+
run: julia deps/build_tarballs.jl
35+
- name: Upload to release
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: deps/gh-update-to-release

.github/workflows/Testing.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Libtask Testing
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
# tags: '*'
8+
release:
9+
pull_request:
10+
types: [opened, synchronize, reopened]
11+
12+
jobs:
13+
test:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
julia-version: ['1.0.5', '1.1.1', '1.2.0', '1.3.0', 'nightly']
18+
julia-arch: [x64, x86]
19+
os: [ubuntu-latest, windows-latest, macOS-latest]
20+
exclude:
21+
- os: macOS-latest
22+
julia-arch: x86
23+
24+
steps:
25+
- uses: actions/[email protected]
26+
- uses: julia-actions/setup-julia@latest
27+
with:
28+
version: ${{ matrix.julia-version }}
29+
- uses: julia-actions/julia-runtest@master

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Libtask
2-
[![Build Status](https://travis-ci.org/TuringLang/Libtask.jl.svg?branch=master)](https://travis-ci.org/TuringLang/Libtask.jl)
3-
[![Build status](https://ci.appveyor.com/api/projects/status/9oj4lh1bdya2ofjm/branch/master?svg=true)](https://ci.appveyor.com/project/TuringLang/libtask-jl/branch/master)
4-
2+
![Libtask Testing](https://github.com/TuringLang/Libtask.jl/workflows/Libtask%20Testing/badge.svg)
3+
![Dylib Build](https://github.com/TuringLang/Libtask.jl/workflows/Build%20Dylib/badge.svg)
54

65

76
C shim for [task copying](https://github.com/JuliaLang/julia/issues/4085) in Turing
@@ -84,4 +83,4 @@ Disclaimer: This feature is still experimental and should only be used with caut
8483
1. Update the new version number in `Project.toml`;
8584
2. Commit all the changes;
8685
3. Tag the current commit with git, the tag name should be version number with a preceding "v";
87-
4. Push the tag to the repo on GitHub.
86+
4. Push the tag to the repo on GitHub, then make a release on the tag.

deps/build_tarballs.jl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,31 @@ name = "LibtaskDylib"
77
version_str = Pkg.TOML.parsefile(joinpath(@__DIR__, "../Project.toml"))["version"] |> strip |> (x) -> lstrip(x, ['v'])
88
version = VersionNumber(version_str)
99

10+
event_file = get(ENV, "GITHUB_EVENT_PATH", "")
11+
# run(`cat $event_file`)
12+
1013
# Collection of sources required to build Libtask
1114
function get_commit_id()
1215
is_pr = get(ENV, "TRAVIS_PULL_REQUEST", "false")
1316
if is_pr != "false"
1417
return get(ENV, "TRAVIS_PULL_REQUEST_SHA", "")
1518
end
16-
return readlines(`git rev-parse HEAD`)[1]
19+
20+
ref = "HEAD"
21+
22+
gaction = get(ENV, "GITHUB_ACTIONS", "")
23+
if !isempty(gaction)
24+
# .pull_request.head.sha, .release.tag_name,
25+
ref = readlines(`jq --raw-output '.pull_request.head.sha' $event_file`)[1]
26+
if ref == "null"
27+
ref = readlines(`jq --raw-output '.release.tag_name' $event_file`)[1]
28+
end
29+
end
30+
31+
if ref == "null"
32+
ref = "HEAD"
33+
end
34+
return readlines(`git rev-parse $ref`)[1]
1735
end
1836

1937
sources = [

deps/gh-update-to-release

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
# -*- mode: sh -*-
3+
4+
# orginal code copied from:
5+
# https://github.com/JasonEtco/upload-to-release/blob/master/upload-to-release
6+
7+
set -e
8+
set -o pipefail
9+
10+
# Ensure that the GITHUB_TOKEN secret is included
11+
if [[ -z "$GITHUB_TOKEN" ]]; then
12+
echo "Set the GITHUB_TOKEN env variable."
13+
exit 1
14+
fi
15+
16+
# Only upload to non-draft releases
17+
IS_DRAFT=$(jq --raw-output '.release.draft' $GITHUB_EVENT_PATH)
18+
if [ "$IS_DRAFT" = true ]; then
19+
echo "This is a draft, so nothing to do!"
20+
exit 0
21+
fi
22+
23+
# Build the Upload URL from the various pieces
24+
RELEASE_ID=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH)
25+
if [[ -z "${RELEASE_ID}" || "${RELEASE_ID}" = null ]]; then
26+
echo "There was no release ID in the GitHub event. Are you using the release event type?"
27+
exit 0
28+
fi
29+
30+
for FILE in $(ls products); do
31+
# Prepare the headers
32+
AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}"
33+
CONTENT_TYPE_HEADER="Content-Type: application/gzip"
34+
CONTENT_LENGTH_HEADER="Content-Length: $(stat -c%s "products/${FILE}")"
35+
36+
UPLOAD_URL="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILE}"
37+
echo "$UPLOAD_URL"
38+
39+
# Upload the file
40+
curl \
41+
-f \
42+
-sSL \
43+
-XPOST \
44+
-H "${AUTH_HEADER}" \
45+
-H "${CONTENT_LENGTH_HEADER}" \
46+
-H "${CONTENT_TYPE_HEADER}" \
47+
--upload-file "products/${FILE}" \
48+
"${UPLOAD_URL}"
49+
done

0 commit comments

Comments
 (0)