Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.github: CICD: add workspace test to build matrix #7386

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,15 @@ jobs:
fail-fast: false
matrix:
job:
# - { os , target , cargo-options , features , use-cross , toolchain, skip-tests }
# - { os , target , cargo-options , features , use-cross , toolchain, skip-tests, workspace-tests }
- { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , features: feat_os_unix_gnueabihf , use-cross: use-cross , skip-tests: true }
- { os: ubuntu-24.04-arm , target: aarch64-unknown-linux-gnu , features: feat_os_unix_gnueabihf }
- { os: ubuntu-latest , target: aarch64-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross , skip-tests: true }
# - { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: feat_selinux , use-cross: use-cross }
- { os: ubuntu-latest , target: i686-unknown-linux-gnu , features: "feat_os_unix,test_risky_names", use-cross: use-cross }
- { os: ubuntu-latest , target: i686-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,test_risky_names", use-cross: use-cross }
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix" , use-cross: no, workspace-tests: true }
- { os: ubuntu-latest , target: x86_64-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
- { os: ubuntu-latest , target: x86_64-unknown-redox , features: feat_os_unix_redox , use-cross: redoxer , skip-tests: true }
- { os: macos-latest , target: aarch64-apple-darwin , features: feat_os_macos } # M1 CPU
Expand Down Expand Up @@ -613,9 +614,12 @@ jobs:
# * CARGO_CMD
CARGO_CMD='cross'
CARGO_CMD_OPTIONS='+${{ env.RUST_MIN_SRV }}'
# Added suffix for artifacts, needed when multiple jobs use the same target.
ARTIFACTS_SUFFIX=''
case '${{ matrix.job.use-cross }}' in
''|0|f|false|n|no)
CARGO_CMD='cargo'
ARTIFACTS_SUFFIX='-nocross'
;;
redoxer)
CARGO_CMD='redoxer'
Expand All @@ -624,6 +628,18 @@ jobs:
esac
outputs CARGO_CMD
outputs CARGO_CMD_OPTIONS
outputs ARTIFACTS_SUFFIX
CARGO_TEST_OPTIONS=''
case '${{ matrix.job.workspace-tests }}' in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice to document here why we have "workspace-tests"?
(afaik, because it doesn't work well because of cross compil, right)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Added a couple of comments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

out of scope but do you think we should move away from the cross image?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure... I'm a bit surprised cross-rs still use 16.04 by default... and... that a new release hasn't happened in 2 years milestone tracking? Development seems active though.

The convenience of cross, and the fact that it's really easy to reproduce CI builds locally, is really nice though...

It is possible to force cross to use a new image though (:main uses 20.04, which is... better already I guess?). It looks like the workspace tests can pass with something like this in Cross.toml:

[build]
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH", 
    "apt-get update && apt-get --assume-yes install libselinux1-dev:$CROSS_DEB_ARCH"
]
[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main"

(the last 2 lines would need to be copy-pasted a few times, I don't see a way to use the :main tag for all targets?! -- and :main syntax is only supported after 0.2.5)

One downside is that the main image is frequently updated, so I guess we'd be at the mercy of upstream breakage, so I think a fixed tag would be slightly safer (we could manually fix a sha if we wanted to, but we'd need to set it for each architecture though, not great in terms of maintenance...)

I think the current solution is still the simplest, and good as a stop-gap at least. But if you want to add --workspace tests for *-musl and i686, we should probably rethink (and check with cross developer on what is blocking a new release).

1|t|true|y|yes)
# This also runs tests in other packages in the source directory (e.g. uucore).
# We cannot enable this everywhere as some platforms are currently broken, and
# we cannot use `cross` as its Docker image is ancient (Ubuntu 16.04) and is
# missing required system dependencies (e.g. recent libclang-dev).
CARGO_TEST_OPTIONS='--workspace'
;;
esac
outputs CARGO_TEST_OPTIONS
# ** pass needed environment into `cross` container (iff `cross` not already configured via "Cross.toml")
if [ "${CARGO_CMD}" = 'cross' ] && [ ! -e "Cross.toml" ] ; then
printf "[build.env]\npassthrough = [\"CI\", \"RUST_BACKTRACE\", \"CARGO_TERM_COLOR\"]\n" > Cross.toml
Expand Down Expand Up @@ -675,6 +691,9 @@ jobs:
esac
case '${{ matrix.job.os }}' in
ubuntu-*)
# selinux headers needed to build tests
sudo apt-get -y update
sudo apt-get -y install libselinux1-dev
# pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd.
# In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands. The account also has empty gecos fields.
# To work around this for pinky tests, we create a fake login entry for the GH runner account...
Expand Down Expand Up @@ -753,7 +772,7 @@ jobs:
- name: Archive executable artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}
name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}${{ steps.vars.outputs.ARTIFACTS_SUFFIX }}
path: target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}
- name: Package
shell: bash
Expand Down
Loading