Skip to content

Commit f363bfe

Browse files
authored
Merge pull request #2955 from GuillaumeGomez/freebsd
Add CI check for FreeBSD
2 parents 64ee425 + 1e4ff66 commit f363bfe

File tree

6 files changed

+85
-0
lines changed

6 files changed

+85
-0
lines changed

.cirrus.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This is ci/actions-templates/linux-builds-template.yaml
2+
# Do not edit this file in .cirrus.yml
3+
4+
task:
5+
name: FreeBSD
6+
freebsd_instance:
7+
image: freebsd-13-0-release-amd64
8+
setup_script: |
9+
pkg install -y git gmake bash
10+
echo "========="
11+
echo "create non-root user and log into it"
12+
pw group add -n tester
13+
pw user add -n tester -g tester -s `which bash`
14+
pw user mod tester -d `pwd`
15+
chown -R tester .
16+
sudo -u tester bash ci/cirrus-templates/script.bash

ci/cirrus-templates/freebsd.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This is ci/actions-templates/linux-builds-template.yaml
2+
# Do not edit this file in .cirrus.yml
3+
4+
task:
5+
name: FreeBSD
6+
freebsd_instance:
7+
image: freebsd-13-0-release-amd64
8+
setup_script: |
9+
pkg install -y git gmake bash
10+
echo "========="
11+
echo "create non-root user and log into it"
12+
pw group add -n tester
13+
pw user add -n tester -g tester -s `which bash`
14+
pw user mod tester -d `pwd`
15+
chown -R tester .
16+
sudo -u tester bash ci/cirrus-templates/script.bash

ci/cirrus-templates/gen-workflows.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
INPATH=$(dirname "$0")
4+
OUTPATH="${INPATH}/../.."
5+
6+
cp freebsd.yaml "$OUTPATH/.cirrus.yml"

ci/cirrus-templates/script.bash

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
# First, we check that this script is not run as root because it would fail tests.
6+
if [ "root" == "$(whoami)" ]; then exit 1; fi
7+
8+
echo "========="
9+
echo "Acquire tags for the repo"
10+
11+
git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/*
12+
13+
echo "========="
14+
echo "Display the current git status"
15+
16+
git status
17+
git describe
18+
19+
echo "========="
20+
echo "Prep cargo dirs"
21+
22+
mkdir -p ~/.cargo/{registry,git}
23+
24+
echo "========="
25+
echo "Install Rustup using ./rustup-init.sh"
26+
27+
sh rustup-init.sh --default-toolchain=stable --profile=minimal -y
28+
# It's the equivalent of `source`
29+
source "$HOME"/.cargo/env
30+
31+
echo "========="
32+
echo "Ensure we have the components we need"
33+
34+
rustup component add rustfmt
35+
rustup component add clippy
36+
37+
echo "========="
38+
echo "Run the freebsd check"
39+
40+
unset SKIP_TESTS
41+
export LIBZ_SYS_STATIC=1
42+
export CARGO_BUILD_JOBS=1
43+
export TARGET="x86_64-unknown-freebsd"
44+
bash ci/run.bash

src/test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ pub fn this_host_triple() -> String {
108108
"apple-darwin"
109109
} else if cfg!(target_os = "illumos") {
110110
"unknown-illumos"
111+
} else if cfg!(target_os = "freebsd") {
112+
"unknown-freebsd"
111113
} else {
112114
unimplemented!()
113115
};

tests/cli-paths.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export PATH="$HOME/apple/bin"
109109
});
110110
}
111111

112+
// This test should NOT be run as root!
112113
#[test]
113114
fn install_errors_when_rc_cannot_be_updated() {
114115
clitools::setup(Scenario::Empty, &|config| {

0 commit comments

Comments
 (0)