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

ci: use rustup instead of actions-rs #2168

Merged
merged 2 commits into from
Mar 27, 2024
Merged

ci: use rustup instead of actions-rs #2168

merged 2 commits into from
Mar 27, 2024

Conversation

toidiu
Copy link
Contributor

@toidiu toidiu commented Mar 26, 2024

Resolved issues:

#2096

Description of changes:

This PR removes actions-rs GHA (deprecated) and replaces it with rustup operations.

Testing:

Existing tests should pass

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Comment on lines 264 to +271
# Build the tests before running to improve cross compilation speed
- name: Run cargo build
uses: actions-rs/cargo@v1.0.3
with:
command: build
args: --tests ${{ matrix.exclude }} ${{ matrix.target != 'native' && format('--target {0}', matrix.target) || '' }} ${{ matrix.args }}
use-cross: ${{ matrix.target != 'native' }}
- name: Run cargo/cross build
run: |
${{ matrix.target != 'native' && 'cross' || 'cargo' }} build --tests ${{ matrix.exclude }} ${{ matrix.target != 'native' && format('--target {0}', matrix.target) || '' }} ${{ matrix.args }}

- name: Run cargo test
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: ${{ matrix.exclude }} ${{ matrix.target != 'native' && format('--target {0}', matrix.target) || '' }} ${{ matrix.args }}
use-cross: ${{ matrix.target != 'native' }}
- name: Run cargo/cross test
run: |
${{ matrix.target != 'native' && 'cross' || 'cargo' }} test ${{ matrix.exclude }} ${{ matrix.target != 'native' && format('--target {0}', matrix.target) || '' }} ${{ matrix.args }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bit verbose. I could split this into different tasks but then we would be repeating ourselves, which given the long list of args seems worse.

- name: build with cargo
  if: ${{ matrix.target == 'native' }}
  run: cargo build

- name: build with cross
  if: ${{ matrix.target != 'native' }}
  run: cross build

Copy link
Contributor

Choose a reason for hiding this comment

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

We might be able to invoke cross regardless? Like if we don't pass a --target to cross does it just default to the host? Or is that a required parameter?

The other option would be to set an env var:

- name: ...
  env:
    CARGO_EXEC: ${{ matrix.target != 'native' && 'cross' || 'cargo' }}
  run: |
    ..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lemme experiment with those options.

Copy link
Contributor Author

@toidiu toidiu Mar 27, 2024

Choose a reason for hiding this comment

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

I tried something similar to the env (bash variable) and ran into issues with windows/powershell having trouble parsing the command $exec build .... I can give that one another try.

Always using cross seems to work but its a bit weird because it always tries to run in a docker container:

  1. on platforms where cross docker images are available, we use the same docker image as the host system

  2. on platforms where a cross docker image is not available, we use cargo // this is good

  3. seems weird because lets say we are on x86_linux and we invoke cross build. We will run inside a docker x86_linux docker container. At the very least this is a behavior change from before. Can we expect full parity between docker and the host system? For a networking library I am a bit hesitant.

Copy link
Contributor

Choose a reason for hiding this comment

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

nah just do what we're doing if that's the case

@toidiu toidiu marked this pull request as ready for review March 26, 2024 21:32
@toidiu toidiu requested a review from camshaft March 26, 2024 21:32
.github/actions/duvet/action.yml Outdated Show resolved Hide resolved
.github/actions/duvet/action.yml Outdated Show resolved Hide resolved
Comment on lines 264 to +271
# Build the tests before running to improve cross compilation speed
- name: Run cargo build
uses: actions-rs/cargo@v1.0.3
with:
command: build
args: --tests ${{ matrix.exclude }} ${{ matrix.target != 'native' && format('--target {0}', matrix.target) || '' }} ${{ matrix.args }}
use-cross: ${{ matrix.target != 'native' }}
- name: Run cargo/cross build
run: |
${{ matrix.target != 'native' && 'cross' || 'cargo' }} build --tests ${{ matrix.exclude }} ${{ matrix.target != 'native' && format('--target {0}', matrix.target) || '' }} ${{ matrix.args }}

- name: Run cargo test
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: ${{ matrix.exclude }} ${{ matrix.target != 'native' && format('--target {0}', matrix.target) || '' }} ${{ matrix.args }}
use-cross: ${{ matrix.target != 'native' }}
- name: Run cargo/cross test
run: |
${{ matrix.target != 'native' && 'cross' || 'cargo' }} test ${{ matrix.exclude }} ${{ matrix.target != 'native' && format('--target {0}', matrix.target) || '' }} ${{ matrix.args }}
Copy link
Contributor

Choose a reason for hiding this comment

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

We might be able to invoke cross regardless? Like if we don't pass a --target to cross does it just default to the host? Or is that a required parameter?

The other option would be to set an env var:

- name: ...
  env:
    CARGO_EXEC: ${{ matrix.target != 'native' && 'cross' || 'cargo' }}
  run: |
    ..

@toidiu toidiu force-pushed the ak-rm_actions-rs branch from dbac5fb to 024aab5 Compare March 27, 2024 18:53
@toidiu toidiu requested a review from camshaft March 27, 2024 18:54
@toidiu toidiu merged commit 47ea5d8 into main Mar 27, 2024
124 checks passed
@toidiu toidiu deleted the ak-rm_actions-rs branch March 27, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants