From c37c1c01b07c531d1992c2ac40e452dd230f8d40 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Tue, 6 Sep 2022 17:57:11 -0700 Subject: [PATCH] Improve caching of Rust build artifacts and update workflows (#565) --- .github/workflows/bump-version.yml | 30 ++----------------- .github/workflows/rust-version.yml | 47 ++---------------------------- .github/workflows/rust.yml | 37 ++--------------------- 3 files changed, 8 insertions(+), 106 deletions(-) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 89e1550b7..a79b1912e 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -10,30 +10,6 @@ on: jobs: bump-version: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - run: rustup update - - run: cargo install --locked --version 0.2.35 cargo-workspaces - - run: | - make bump-version VERSION=${{ inputs.version }} - - name: Create Commit - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git checkout -b 'bump-version-${{ inputs.version }}' - git add . - git commit -m 'Bump version to ${{ inputs.version }}' - git push origin 'bump-version-${{ inputs.version }}' - - name: Create Pull Request - uses: actions/github-script@v6 - with: - script: | - await github.rest.pulls.create({ - title: 'Bump version to ${{ inputs.version }}', - owner: context.repo.owner, - repo: context.repo.repo, - head: 'bump-version-${{ inputs.version }}', - base: 'main', - body: '### What\nBump version to ${{ inputs.version }}.\n\n### Why\nTriggered by ${{ github.actor }}.' - }); + uses: stellar/actions/.github/workflows/rust-bump-version.yml@main + with: + version: ${{ inputs.version }} diff --git a/.github/workflows/rust-version.yml b/.github/workflows/rust-version.yml index d1ffb417a..4fc93c421 100644 --- a/.github/workflows/rust-version.yml +++ b/.github/workflows/rust-version.yml @@ -7,48 +7,5 @@ on: jobs: - check-and-update-rust-version: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - run: rustup update - - run: cargo install --locked --version 0.2.0 cargo-set-rust-version - - # Update the rust-version in all workspace crates to the latest stable - # version. - - run: cargo set-rust-version - - # Check if there is any diff resulting from updating the crates. If there is - # set the update=true output for following steps. - - id: diff - run: | - if ! git diff --exit-code; then - echo "::set-output name=update::true" - fi - - # If the diff step indicates an update is required, create a branch and push - # it to GitHub. If the branch already exists with a change the push should - # fail, and so we shouldn't end up with multiple PRs. - - if: steps.diff.outputs.update == 'true' - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git checkout -b update-rust-version - git add . - git commit -m 'Update rust-version' - git push origin update-rust-version - - # If the diff step indicates an update is required, open a PR. - - if: steps.diff.outputs.update == 'true' - name: Create Pull Request - uses: actions/github-script@v6 - with: - script: | - await github.rest.pulls.create({ - title: 'Update rust-version', - owner: context.repo.owner, - repo: context.repo.repo, - head: 'update-rust-version', - base: 'main', - body: '### What\nUpdate rust-version to latest stable.\n\n### Why\nTracking latest stable which receives security updates.' - }); + set-rust-version: + uses: stellar/actions/.github/workflows/rust-set-rust-version.yml@main diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index def459e68..c7b632dd3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -45,26 +45,10 @@ jobs: runs-on: ${{ matrix.sys.os }} steps: - uses: actions/checkout@v3 + - uses: stellar/actions/rust-cache@main - run: rustup update - run: rustup target add ${{ matrix.sys.target }} - run: rustup target add wasm32-unknown-unknown - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: cargo- - - uses: actions/cache@v3 - with: - path: target/ - key: ${{ github.job }}-target-${{ strategy.job-index }}-${{ github.sha }} - restore-keys: | - ${{ github.job }}-target-${{ strategy.job-index }} - ${{ github.job }}-target- - - if: github.ref_protected - run: rm -fr target - run: cargo install --locked --version 0.5.16 cargo-hack - run: cargo hack build --target wasm32-unknown-unknown --profile release - run: cargo hack --feature-powerset --exclude-features docs build --target ${{ matrix.sys.target }} @@ -74,24 +58,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: stellar/actions/rust-cache@main - run: rustup install nightly - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: cargo- - - uses: actions/cache@v3 - with: - path: target/ - key: ${{ github.job }}-target-${{ github.sha }} - restore-keys: | - ${{ github.job }}-target - ${{ github.job }}-target- - - if: github.ref_protected - run: rm -fr target - run: make doc publish: @@ -100,6 +68,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: stellar/actions/rust-cache@main - run: rustup update - run: cargo install --locked --version 0.2.35 cargo-workspaces - run: make publish