Skip to content

Commit

Permalink
Improve caching of Rust build artifacts and update workflows (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored Sep 7, 2022
1 parent d7f92c6 commit c37c1c0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 106 deletions.
30 changes: 3 additions & 27 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
47 changes: 2 additions & 45 deletions .github/workflows/rust-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
37 changes: 3 additions & 34 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit c37c1c0

Please sign in to comment.