-
Notifications
You must be signed in to change notification settings - Fork 6
150 lines (137 loc) · 4.9 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: Build with rust and docker
on:
push:
pull_request:
schedule:
# Fetch new base image updates every night at 1am
- cron: '0 1 * * *'
env:
CARGO_TERM_COLOR: always
PROFILE: release
jobs:
pre-check:
name: Security, License Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
build-rust:
name: Build (Rust)
runs-on: ubuntu-20.04
strategy:
matrix:
arch:
- amd64
- arm64
features:
- ""
- "sockets"
steps:
- name: Print matrix vars
run: |
echo "Arch: ${{ matrix.arch }}"
echo "Features: ${{ matrix.features }}"
- name: Set arch ${{ matrix.arch }}
env:
ARCH: ${{ matrix.arch }}
run: |
if [ "${ARCH}" == "arm64" ]; then
echo "rustarch=aarch64-unknown-linux-gnu" >> $GITHUB_ENV
elif [ "${ARCH}" == "amd64" ]; then
echo "rustarch=x86_64-unknown-linux-gnu" >> $GITHUB_ENV
else
exit 1
fi
if [ "$(dpkg --print-architecture)" != "${ARCH}" ]; then
echo "Cross-compiling to ${ARCH}."
echo "is_cross=true" >> $GITHUB_ENV
else
echo "Natively compiling to ${ARCH}."
echo "is_cross=false" >> $GITHUB_ENV
fi
- name: Set profile ${{ env.PROFILE }}
env:
PROFILE: ${{ env.PROFILE }}
run: |
if [ "${PROFILE}" == "release" ]; then
echo "profilestr=--release" >> $GITHUB_ENV
elif [ "${PROFILE}" == "debug" ]; then
echo "profilestr=" >> $GITHUB_ENV
else
echo "profilestr=--profile $PROFILE" >> $GITHUB_ENV
fi
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
target: ${{ env.rustarch }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.arch }}-${{ env.PROFILE }}
prefix-key: v1-rust-${{ matrix.features && format('features_{0}', matrix.features) || 'nofeatures' }} # Increase to invalidate old caches.
- name: Build (${{ matrix.arch }})
uses: actions-rs/cargo@v1
with:
use-cross: ${{ env.is_cross }}
command: build
args: --target ${{ env.rustarch }} ${{ matrix.features && format('--features {0}', matrix.features) }} ${{ env.profilestr }}
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: binaries-${{ matrix.arch }}-${{ matrix.features }}
path: |
target/${{ env.rustarch }}/${{ env.PROFILE }}/proxy
target/${{ env.rustarch }}/${{ env.PROFILE }}/broker
test:
name: Run tests
needs: [ build-rust ]
runs-on: ubuntu-22.04
strategy:
matrix:
features:
- ""
- "sockets"
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: binaries-amd64-${{ matrix.features }}
path: artifacts/binaries-amd64/
- run: ./dev/test ci ${{ matrix.features && format('--features {0}', matrix.features) }}
docker:
needs: [ build-rust, pre-check, test ]
strategy:
matrix:
components:
- broker
- proxy
features:
- ""
- "sockets"
# This workflow defines how a maven package is built, tested and published.
# Visit: https://github.com/samply/github-workflows/blob/develop/.github/workflows/docker-ci.yml, for more information
uses: samply/github-workflows/.github/workflows/docker-ci.yml@main
with:
# The Docker Hub Repository you want eventually push to, e.g samply/share-client
image-name: "samply/beam-${{ matrix.components }}"
image-tag-suffix: ${{ matrix.features && format('-{0}', matrix.features) }}
# Define special prefixes for docker tags. They will prefix each images tag.
# image-tag-prefix: "foo"
# Define the build context of your image, typically default '.' will be enough
# build-context: '.'
# Define the Dockerfile of your image, typically default './Dockerfile' will be enough
build-file: './Dockerfile'
# NOTE: This doesn't work currently
# A list of build arguments, passed to the docker build
build-args: |
FEATURE=-${{ matrix.features }}
COMPONENT=${{ matrix.components }}
# Define the target platforms of the docker build (default "linux/amd64,linux/arm64/v8")
# build-platforms: "linux/amd64"
# If your actions generate an artifact in a previous build step, you can tell this workflow to download it
artifact-name: '*'
# This passes the secrets from calling workflow to the called workflow
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}