-
Notifications
You must be signed in to change notification settings - Fork 19
Revive CI with GH Workflows #6
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
Merged
newpavlov
merged 3 commits into
RustCrypto:master
from
aewag:revive-ci-with-gh-workflows
Jan 26, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: "cross-tests" | ||
|
|
||
| inputs: | ||
| rust: | ||
| required: true | ||
| package: | ||
| required: true | ||
| target: | ||
| required: true | ||
| features: | ||
| required: true | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions-rs/toolchain@v1 | ||
| with: | ||
| profile: minimal | ||
| toolchain: ${{ inputs.rust }} | ||
| target: ${{ inputs.target }} | ||
| override: true | ||
| - name: Install precompiled cross | ||
| run: | | ||
| export URL=$(curl -s https://api.github.com/repos/cross-rs/cross/releases/latest | \ | ||
| jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url') | ||
| wget -O /tmp/binaries.tar.gz $URL | ||
| tar -C /tmp -xzf /tmp/binaries.tar.gz | ||
| mv /tmp/cross ~/.cargo/bin | ||
| shell: bash | ||
| - if: ${{ inputs.features != 'NO_FEATURE' }} | ||
| run: | | ||
| cd ${{ inputs.package }} | ||
| cross test --target ${{ inputs.target }} --no-default-features \ | ||
| --features ${{ inputs.features }} | ||
| shell: bash | ||
| - if: ${{ inputs.features == 'NO_FEATURE' }} | ||
| run: | | ||
| cd ${{ inputs.package }} | ||
| cross test --target ${{ inputs.target }} --no-default-features | ||
| shell: bash | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: cargo | ||
| directory: "/" | ||
| schedule: | ||
| interval: daily | ||
| open-pull-requests-limit: 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| name: keccak | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - ".github/workflows/keccak.yml" | ||
| - "keccak/**" | ||
| - "Cargo.*" | ||
| push: | ||
| branches: master | ||
|
|
||
| defaults: | ||
| run: | ||
| working-directory: keccak | ||
|
|
||
| env: | ||
| MSRV: 1.41.0 | ||
| RUSTFLAGS: "-Dwarnings" | ||
| CARGO_INCREMENTAL: 0 | ||
|
|
||
| jobs: | ||
| set-msrv: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| msrv: ${{ steps.msrv.outputs.msrv }} | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - id: msrv | ||
| run: echo "::set-output name=msrv::$(echo $MSRV)" | ||
|
|
||
| build: | ||
| needs: set-msrv | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| rust: | ||
| - ${{needs.set-msrv.outputs.msrv}} | ||
| - stable | ||
| target: | ||
| - thumbv7em-none-eabi | ||
| - wasm32-unknown-unknown | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions-rs/toolchain@v1 | ||
| with: | ||
| profile: minimal | ||
| toolchain: ${{ matrix.rust }} | ||
| target: ${{ matrix.target }} | ||
| override: true | ||
| - run: cargo build --no-default-features --target ${{ matrix.target }} | ||
|
|
||
| test: | ||
| needs: set-msrv | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| rust: | ||
| - ${{needs.set-msrv.outputs.msrv}} | ||
| - stable | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions-rs/toolchain@v1 | ||
| with: | ||
| profile: minimal | ||
| toolchain: ${{ matrix.rust }} | ||
| override: true | ||
| - run: cargo check --all-features | ||
| - run: cargo test --no-default-features | ||
| - run: cargo test | ||
| - run: cargo test --all-features | ||
|
|
||
| # Cross-compiled tests | ||
| cross: | ||
| needs: set-msrv | ||
| strategy: | ||
| matrix: | ||
| rust: | ||
| - ${{needs.set-msrv.outputs.msrv}} | ||
| - stable | ||
| target: | ||
| - i686-unknown-linux-gnu | ||
| - x86_64-unknown-linux-gnu | ||
| - aarch64-unknown-linux-gnu | ||
| - mips-unknown-linux-gnu | ||
| features: | ||
| - no_unroll | ||
| - 'NO_FEATURE' | ||
|
|
||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| # Cross mounts only current package, i.e. by default it ignores workspace's Cargo.toml | ||
| working-directory: . | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: ./.github/actions/cross-tests | ||
| with: | ||
| rust: ${{ matrix.rust }} | ||
| package: ${{ github.workflow }} | ||
| target: ${{ matrix.target }} | ||
| features: ${{ matrix.features }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Security Audit | ||
| on: | ||
| pull_request: | ||
| paths: Cargo.lock | ||
| push: | ||
| branches: master | ||
| paths: Cargo.lock | ||
| schedule: | ||
| - cron: "0 0 * * *" | ||
|
|
||
| jobs: | ||
| security_audit: | ||
| name: Security Audit | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v1 | ||
| - name: Cache cargo bin | ||
| uses: actions/cache@v1 | ||
| with: | ||
| path: ~/.cargo/bin | ||
| key: ${{ runner.os }}-cargo-audit-v0.12.0 | ||
| - uses: actions-rs/audit-check@v1 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: Workspace | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths-ignore: | ||
| - README.md | ||
| push: | ||
| branches: master | ||
| paths-ignore: | ||
| - README.md | ||
|
|
||
| jobs: | ||
| clippy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v1 | ||
| - uses: actions-rs/toolchain@v1 | ||
| with: | ||
| toolchain: stable | ||
| components: clippy | ||
| profile: minimal | ||
| override: true | ||
| - run: cargo clippy --all -- -D warnings | ||
|
|
||
| rustfmt: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@v1 | ||
|
|
||
| - name: Install stable toolchain | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| toolchain: stable | ||
| components: rustfmt | ||
| profile: minimal | ||
| override: true | ||
|
|
||
| - name: Run cargo fmt | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: fmt | ||
| args: --all -- --check |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious how much time this actually saves versus
cargo install cross, which we use elsewhere:https://github.com/RustCrypto/elliptic-curves/blob/89d6ab4/.github/workflows/k256.yml#L136
Looking at the CI history, it takes about 1m11s
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I also thought about using
cargo install cross. The benefit is not too big for the more complex CI code.crosswithin my fork takes 30 - 40 seconds for a single run.https://github.com/aewag/sponges/actions/runs/1745945800
I can push a variant using
cargo install, and we can see if it performs much worse.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, there seems to be a different issue than performance:
The current
MSRVof thekeccakcrate is 1.41. But this is not sufficient to build cross [1]. So best is probably to work with the precompiledcross. I removed the WIP commit for experimenting withcargo install.[1] https://github.com/aewag/sponges/runs/4940099815?check_suite_focus=true#step:3:170
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok to bump MSRV, especially if we're making breaking changes anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't than the MSRV of cross the bottomline MSRV of keccak?
I just pushed a WIP with MSRV 1.46. This succeeds building
cross. Interestingly prior versions fail [1], although cross MSRV is 1.42. Not really sure why this is the case.Performance-wise it takes 2m for a single run compared to 30-40s with a precompiled binary.
[1] https://github.com/aewag/sponges/runs/4942085469?check_suite_focus=true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,
set-msrvis a candidate to be moved into a reusable workflow. For example, this would easily allow an extension to get the MSRV from theCargo.tomlinstead of hardcoding it in the CI config. I think for such extensions it is nice to have common patterns at a single place.I suggest to install
crossusing a composite action. This seems to me the most lightweight approach, that is currently available. Ifactions-rsgets extended orcrosssupports better options to install, we could simply switch to that by modifying this action only.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@newpavlov WDYT? Should we give it a try?
It seems like we could use
set-msrveverywhere to have MSRV specified once per workflow.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tarcieri
Yeah, go ahead. We always can revert everything back if it will be too much trouble in the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a repo here: https://github.com/RustCrypto/actions
@aewag feel free to upstream the work there! It seems like we'll be able to unify the configs in
spongesandhashesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, we'll do that. 👍