-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (103 loc) · 3.76 KB
/
build.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
name: Build
env:
# build job configuration
STYLE_FAIL_ON_FAULT: true ## (bool) fail if the build job contains a fault (error or warning); may be overridden on a per-job basis
on:
# To run manually workflow
workflow_dispatch:
# Run with new tag
# push:
# tags:
# - '*'
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
build:
name: Build cargo-nextest
runs-on: ubuntu-latest
timeout-minutes: 90
# strategy:
# fail-fast: false
steps:
# Checkout only build script
- name: Checkout build script
uses: actions/checkout@v4
with:
sparse-checkout: |
build.sh
sparse-checkout-cone-mode: false
# Prepare OpenBSD-stable VM and run build
- name: Prepare OpenBSD VM and build
uses: vmactions/[email protected]
with:
usesh: true
sync: rsync
copyback: false
# Install requirements to build cargo-nextest with Rust v1.72.1
prepare: |
pkg_add -I bash curl git sudo-1.9.14.2
pkg_add -I rust zstd
run: |
## Prepare, build, and test
# implementation modelled after ref: <https://github.com/rust-lang/rustup/pull/2783>
# * NOTE: All steps need to be run in this block, otherwise, we are operating back on the Ubuntu host
set -e
#
BUILD_USER=builder
REPO_NAME=${GITHUB_WORKSPACE##*/}
WORKSPACE_PARENT="/home/runner/work/${REPO_NAME}"
WORKSPACE="${WORKSPACE_PARENT}/${REPO_NAME}"
# Generate random password for user
PASSWD=$(encrypt $(openssl rand -base64 12))
# Create user for build
useradd -d /root/ -g wheel -c "User to buildi cargo-nextest" -p ${PASSWD} ${BUILD_USER}
chown -R ${BUILD_USER}:wheel /root/ "${WORKSPACE_PARENT}"/
whoami
#
# Further work needs to be done in a sudo as we are changing users
sudo -i -u ${BUILD_USER} bash << EOF
set -e
whoami
# Increase the number of file descriptors - See https://github.com/rust-lang/cargo/issues/11435
ulimit -n 1024
## VARs setup
cd "${WORKSPACE}"
unset FAIL_ON_FAULT ; case '${{ env.STYLE_FAIL_ON_FAULT }}' in
''|0|f|false|n|no|off) FAULT_TYPE=warning ;;
*) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;;
esac;
FAULT_PREFIX=\$(echo "\${FAULT_TYPE}" | tr '[:lower:]' '[:upper:]')
## Info
# environment
echo "## environment"
echo "CI='${CI}'"
echo "REPO_NAME='${REPO_NAME}'"
echo "BUILD_USER='${BUILD_USER}'"
echo "WORKSPACE_PARENT='${WORKSPACE_PARENT}'"
echo "WORKSPACE='${WORKSPACE}'"
echo "FAULT_PREFIX='\${FAULT_PREFIX}'"
env | sort
# tooling info
echo "## tooling infos"
cargo -V
rustc -V
echo "## packages infos"
pkg_info
## Run build script for cargo-nextest
echo "##################################"
echo "Run build script for cargo-nextest"
echo "##################################"
./build.sh
echo "# ls -l /tmp/cargo-nextest-build-0.9.66/target/release"
ls -l /tmp/cargo-nextest-build-0.9.66/target/release
echo "# /tmp/cargo-nextest-build-0.9.66/target/release/cargo-nextest -V"
/tmp/cargo-nextest-build-0.9.66/target/release/cargo-nextest -V
#
# To ensure that files are cleaned up, we don't want to exit on error
#
set +e
unset FAULT
# Clean to avoid to rsync back the files
cargo clean
if [ -n "\${FAIL_ON_FAULT}" ] && [ -n "\${FAULT}" ]; then exit 1 ; fi
EOF