Add --quiet #16
This file contains 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
name: Sync Rust STD | |
on: | |
push: | |
branches: | |
- '**' | |
workflow_dispatch: | |
env: | |
REPO_OWNER: model-checking | |
REPO_NAME: kani | |
BRANCH_NAME: features/verify-rust-std | |
jobs: | |
prepare: | |
runs-on: ${{ matrix.os }} | |
outputs: | |
commit_hash: ${{ steps.rust-info.outputs.commit_hash }} | |
commit_date: ${{ steps.rust-info.outputs.commit_date }} | |
toolchain_date: ${{ steps.toolchain-date.outputs.toolchain_date }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- name: Checkout library | |
uses: actions/checkout@v3 | |
with: | |
path: head | |
- name: Checkout `features/verify-rust-std` | |
uses: actions/checkout@v4 | |
with: | |
repository: model-checking/kani | |
path: kani | |
ref: features/verify-rust-std | |
- name: Read date from rust-toolchain.toml | |
id: toolchain-date | |
working-directory: kani | |
run: | | |
TOOLCHAIN_DATE=$(grep 'channel.*=.*"nightly-' ./rust-toolchain.toml | sed -E 's/.*nightly-([0-9-]+).*/\1/') | |
if [ -z "$TOOLCHAIN_DATE" ]; then | |
echo "Error: Could not extract date from rust-toolchain file." | |
exit 1 | |
fi | |
echo "toolchain_date=$TOOLCHAIN_DATE" >> $GITHUB_OUTPUT | |
- name: Build `Kani` | |
working-directory: kani | |
run: | | |
cargo build-dev --release | |
echo "$(pwd)/scripts" >> $GITHUB_PATH | |
- name: Get Rust info | |
working-directory: kani | |
id: rust-info | |
run: | | |
RUSTC_INFO=$(rustc --version --verbose) | |
COMMIT_HASH=$(echo "$RUSTC_INFO" | grep 'commit-hash' | awk '{print $2}') | |
COMMIT_DATE=$(echo "$RUSTC_INFO" | grep 'commit-date' | awk '{print $2}') | |
echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT | |
echo "commit_date=$COMMIT_DATE" >> $GITHUB_OUTPUT | |
sanity-check: | |
needs: prepare | |
runs-on: ubuntu-latest | |
steps: | |
- name: Echo gathered variables | |
run: | | |
echo "Commit Hash: ${{ needs.prepare.outputs.commit_hash }}" | |
echo "Commit Date: ${{ needs.prepare.outputs.commit_date }}" | |
echo "Toolchain Date: ${{ needs.prepare.outputs.toolchain_date }}" | |
sync: | |
needs: prepare | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout library | |
uses: actions/checkout@v3 | |
with: | |
path: head | |
- name: Add upstream remote and fetch specific commit | |
working-directory: head | |
run: | | |
git remote add upstream https://github.com/rust-lang/rust.git | |
git remote set-url origin https://github.com/model-checking/verify-rust-std.git | |
git fetch upstream ${{ needs.prepare.outputs.commit_hash }} | |
git remote -v | |
- name: Prepare sync branch | |
working-directory: head | |
run: | | |
SYNC_BRANCH="sync-${{ needs.prepare.outputs.toolchain_date }}" | |
echo "SYNC_BRANCH=$SYNC_BRANCH" >> $GITHUB_ENV | |
echo "--- Fork branch: ${SYNC_BRANCH} ---" | |
git checkout ${{ needs.prepare.outputs.commit_hash }} | |
git pull upstream ${{ needs.prepare.outputs.commit_hash }} | |
- name: Update and merge subtree | |
working-directory: head | |
run: | | |
git subtree split --prefix=library --onto subtree/library -b subtree/library | |
git fetch origin | |
git checkout -b ${{ env.SYNC_BRANCH }} origin/main | |
- name: Attempt subtree merge | |
working-directory: head | |
run: | | |
if ! git subtree merge --prefix=library subtree/library --squash --quiet; then | |
echo "Merge conflict detected. Attempting automatic resolution." | |
# Abort the failed merge | |
git merge --abort | |
# Attempt the merge again with the 'ours' strategy | |
if git subtree merge --prefix=library subtree/library --squash -X ours; then | |
echo "Merge conflicts automatically resolved using 'ours' strategy." | |
echo "MERGE_AUTO_RESOLVED=true" >> $GITHUB_ENV | |
else | |
echo "Failed to automatically resolve merge conflicts." | |
echo "MERGE_FAILED=true" >> $GITHUB_ENV | |
exit 1 | |
fi | |
fi | |
- name: Check auto-resolved changes | |
if: env.MERGE_AUTO_RESOLVED == 'true' | |
run: | | |
echo "Merge was auto-resolved. Here are the changes:" | |
git diff --name-status HEAD~1 | |
# You might want to run tests or other checks here to ensure | |
# the auto-resolution didn't break anything |