forked from franchb/ballista
-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (132 loc) · 4.98 KB
/
rust.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Rust
on:
push:
paths:
- rust/**
pull_request:
paths:
- rust**
workflow_dispatch:
# Note, toolchain version must match the rustup version: either "nightly" or "nightly-YYYY-MM-DD"
# and must contain the toolchain for the OS at the end.
env:
VCPKGRS_DYNAMIC: 1
#TOOLCHAIN_VERSION: stable-x86_64-pc-windows-msvc
jobs:
PreTestChecks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Lint Ballista
run: cd rust && cargo clippy -- -D warnings
- name: Check Ballista formatting
run: cd rust && cargo fmt -- --check
Ubuntu:
runs-on: ubuntu-latest
needs: [PreTestChecks]
steps:
- uses: actions/checkout@v2
- name: Build Ballista
run: cd rust && cargo build
- name: Run tests
run: cd rust && cargo test
Mac:
runs-on: macos-latest
needs: [PreTestChecks]
steps:
- uses: actions/checkout@v2
- name: Build Ballista
run: cd rust && cargo build
- name: Run tests
run: cd rust && cargo test
Windows:
runs-on: windows-2016
needs: [PreTestChecks]
steps:
- uses: actions/checkout@v2
- name: Setup environment variables
run: |
#Setting up openssl version variable
$package_md = vcpkg search openssl | Select-String -Pattern "^openssl\s+[^\s]+\s+.*$"
if ($package_md.Count -gt 1){
echo "::error::vcpkg found many packages matching regex instead of one: $package_md"
}
if ($package_md.Count -eq 0){
echo "::error::vcpkg could not find any packages matching the regex"
}
$version = [regex]::match($package_md, '^openssl\s+([^\s]+)\s+.*$').Groups[1].Value
echo "MOST_RECENT_OPENSSL_VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- uses: actions/cache@v2
id: cache_openssl
with:
path: |
vcpkg-cache
key: ${{ runner.os }}-cache-openssl-${{env.MOST_RECENT_OPENSSL_VERSION}}
- name: Prepare the Windows Build Environment
run: |
$abs_path = "{0}\vcpkg-cache" -f $pwd
vcpkg integrate install
vcpkg install openssl:x64-windows --binarysource="files,$abs_path,readwrite"
- name: Build Ballista
run: |
cd rust && cargo build
- name: Run tests
run: |
cd rust && cargo test
Docker:
runs-on: ubuntu-latest
env:
# this points to the repository that others fork from. Useful to fetch cached images from
BASE_REPOSITORY: ballista-compute/ballista
BUILDER_IMAGE_NAME: docker.pkg.github.com/${{ github.repository }}/ballista-rust-builder
IMAGE_NAME: docker.pkg.github.com/${{ github.repository }}/ballista-rust
steps:
- uses: actions/checkout@v2
# github does not provide a clean ref name. We build it here, see https://stackoverflow.com/a/58035262/931303
- name: Extract git reference name
shell: bash
run: echo "##[set-output name=ref;]$(A=${GITHUB_REF#refs/heads/}; A=${A#refs/pulls/}; echo ${A////.})"
id: extract_ref
# login to docker so that we can pull images from it.
- name: Docker login
run: docker login docker.pkg.github.com -u $GITHUB_ACTOR -p $GITHUB_TOKEN
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
# try to fetch the latest builder image, so that we can re-use cached layers from it
# it tries fetching it from the following places in order
# - current fork, ref name
# - base repo, main
- name: Pull builder image
run: >
docker pull "$BUILDER_IMAGE_NAME:${{ steps.extract_ref.outputs.ref }}" ||
docker pull "docker.pkg.github.com/$BASE_REPOSITORY/ballista-rust-builder:main" ||
true
# build the builder image and push it so that it is available for caching
- name: Build builder image
run: >
docker build -f docker/rust.dockerfile
--cache-from $BUILDER_IMAGE_NAME:${{ steps.extract_ref.outputs.ref }}
--cache-from docker.pkg.github.com/$BASE_REPOSITORY/ballista-rust-builder:main
-t $BUILDER_IMAGE_NAME:${{ steps.extract_ref.outputs.ref }}
--target builder
.
- name: Push builder image
# we can't push images on pull requests, as tokens only allow read access (for security reasons)
if: github.event_name != 'pull_request'
run: docker push $BUILDER_IMAGE_NAME:${{ steps.extract_ref.outputs.ref }}
- name: Build image
run: >
docker build -f docker/rust.dockerfile
--cache-from $BUILDER_IMAGE_NAME:${{ steps.extract_ref.outputs.ref }}
-t $IMAGE_NAME:${{ steps.extract_ref.outputs.ref }}
.
- name: Push image
# we can't push images on pull requests, as tokens only allow read access (for security reasons)
if: github.event_name != 'pull_request'
run: docker push $IMAGE_NAME:${{ steps.extract_ref.outputs.ref }}
# IntegrationTests:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Run integration tests
# run: bash dev/integration-tests.sh