Skip to content

Commit

Permalink
Fix CI env (paritytech#511)
Browse files Browse the repository at this point in the history
* Fix CI env

* dir

* script2yml

* remove HAED_REF

* format shell

* $env

* add global env

* remove CARGO_HOME

* yml2script
  • Loading branch information
General-Beck authored Nov 17, 2020
1 parent e0f2e08 commit ec50557
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
SCCACHE_IDLE_TIMEOUT: 0
CMAKE_C_COMPILER_LAUNCHER: sccache
CMAKE_CXX_COMPILER_LAUNCHER: sccache
CARGO_TARGET_DIR: "/cache/${{ github.head_ref }}/${{ matrix.toolchain }}/"
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.4.1
Expand All @@ -49,16 +50,17 @@ jobs:
run: rustup toolchain add nightly-2020-10-04
- name: Add WASM Utilities
run: rustup target add wasm32-unknown-unknown --toolchain nightly-2020-10-04
- name: Configure CARGO_HOME & CARGO_TARGET_DIR
run: ./scripts/ci-cache.sh "${{ github.head_ref }}" "${{ matrix.toolchain }}"
- name: Configure CARGO_TARGET_DIR
shell: bash
run: ./scripts/ci-cache.sh
- name: Cache checking
if: github.event_name == 'pull_request' && github.event.action == 'opened' || github.event.action == 'reopened'
continue-on-error: true
run: |
echo "Copy cache from master";
apt update&&apt install rsync -y;
# TODO add rsync in docker
rsync -aq /cache/${{ matrix.toolchain }}/ $CARGO_TARGET_DIR/ || true;
echo "Copy cache from master";
apt update&&apt install rsync -y;
# TODO add rsync in docker
rsync -aq /cache/${{ matrix.toolchain }}/ $CARGO_TARGET_DIR/ || true;
shell: bash
- name: Sccache stats
run: sccache --show-stats
Expand Down
21 changes: 6 additions & 15 deletions scripts/ci-cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,18 @@

set -xeu

HEAD_REF=$1
TOOLCHAIN=$2

CARGO_HOME=/cache/$HEAD_REF/$TOOLCHAIN
CARGO_TARGET_DIR=/cache/$HEAD_REF/$TOOLCHAIN

echo "::set-env name=CARGO_HOME::$CARGO_HOME"
echo "::set-env name=CARGO_TARGET_DIR::$CARGO_TARGET_DIR"

echo $CARGO_TARGET_DIR;
mkdir -p $CARGO_TARGET_DIR;
echo "Current Rust nightly version:";
rustc +nightly --version;
echo "Cached Rust nightly version:";
if [ ! -f $CARGO_TARGET_DIR/check_nightly_rust ]; then
echo "" > $CARGO_TARGET_DIR/check_nightly_rust;
echo "" > $CARGO_TARGET_DIR/check_nightly_rust;
fi
cat $CARGO_TARGET_DIR/check_nightly_rust;
if [[ $(cat $CARGO_TARGET_DIR/check_nightly_rust) == $(rustc +nightly --version) ]];
then echo "The Rust nightly version has not changed";
if [[ $(cat $CARGO_TARGET_DIR/check_nightly_rust) == $(rustc +nightly --version) ]]; then
echo "The Rust nightly version has not changed";
else
echo "The Rust nightly version has changed. Clearing the cache";
rm -rf $CARGO_TARGET_DIR/*;
echo "The Rust nightly version has changed. Clearing the cache";
rm -rf $CARGO_TARGET_DIR/*;
fi

0 comments on commit ec50557

Please sign in to comment.