]> git.lizzy.rs Git - rust.git/blobdiff - .github/workflows/ci.yaml
pin cache action
[rust.git] / .github / workflows / ci.yaml
index a5a4b3ccd66cb200a7cd10d50173fef3c70b631a..1145fcfab1cfc0c1120d4f0449b16e34d2849f7d 100644 (file)
@@ -12,29 +12,15 @@ env:
   CARGO_NET_RETRY: 10
   CI: 1
   RUST_BACKTRACE: short
-  RUSTFLAGS: -D warnings
+  RUSTFLAGS: "-D warnings -W unreachable-pub"
   RUSTUP_MAX_RETRIES: 10
 
 jobs:
-  rust-audit:
-    name: Audit Rust vulnerabilities
-    runs-on: ubuntu-latest
-    steps:
-    - name: Checkout repository
-      uses: actions/checkout@v2
-
-    - uses: actions-rs/install@v0.1
-      with:
-        crate: cargo-audit
-        use-tool-cache: true
-
-    - run: cargo audit
-
   rust:
     name: Rust
     runs-on: ${{ matrix.os }}
     env:
-     CC: deny_c
+      CC: deny_c
 
     strategy:
       fail-fast: false
@@ -44,6 +30,9 @@ jobs:
     steps:
     - name: Checkout repository
       uses: actions/checkout@v2
+      with:
+        ref: ${{ github.event.pull_request.head.sha }}
+        fetch-depth: 20
 
     # We need to disable the existing toolchain to avoid updating rust-docs
     # which takes a long time. The fastest way to do this is to rename the
@@ -61,26 +50,8 @@ jobs:
         override: true
         components: rustfmt, rust-src
 
-    - if: matrix.os == 'ubuntu-latest'
-      run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
-
-    - name: Cache cargo registry
-      uses: actions/cache@v1
-      with:
-        path: ~/.cargo/registry
-        key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
-
-    - name: Cache cargo index
-      uses: actions/cache@v1
-      with:
-        path: ~/.cargo/git
-        key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
-
-    - name: Cache cargo target dir
-      uses: actions/cache@v1
-      with:
-        path: target
-        key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
+    - name: Cache Dependencies
+      uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
 
     - name: Compile
       run: cargo test --no-run --locked
@@ -88,18 +59,14 @@ jobs:
     - name: Test
       run: cargo test
 
-    - name: Prepare cache
-      run: cargo xtask pre-cache
-
-    - name: Prepare cache 2
-      if: matrix.os == 'windows-latest'
-      run: Remove-Item ./target/debug/xtask.exe, ./target/debug/deps/xtask.exe
-
-  # Weird target to catch non-portable code
-  rust-power:
-    name: Rust Power
+  # Weird targets to catch non-portable code
+  rust-cross:
+    name: Rust Cross
     runs-on: ubuntu-latest
 
+    env:
+      targets: "powerpc-unknown-linux-gnu x86_64-unknown-linux-musl"
+
     steps:
     - name: Checkout repository
       uses: actions/checkout@v2
@@ -110,31 +77,25 @@ jobs:
         toolchain: stable
         profile: minimal
         override: true
-        target: 'powerpc-unknown-linux-gnu'
-
-    - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
 
-    - name: Cache cargo registry
-      uses: actions/cache@v1
-      with:
-        path: ~/.cargo/registry
-        key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
+    - name: Install Rust targets
+      run: rustup target add ${{ env.targets }}
 
-    - name: Cache cargo index
-      uses: actions/cache@v1
-      with:
-        path: ~/.cargo/git
-        key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
+    - name: Cache Dependencies
+      uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
 
     - name: Check
-      run: cargo check --target=powerpc-unknown-linux-gnu --all-targets
+      run: |
+        for target in ${{ env.targets }}; do
+          cargo check --target=$target --all-targets
+        done
 
   typescript:
     name: TypeScript
     strategy:
       fail-fast: false
       matrix:
-        os: [ubuntu-latest, windows-latest, macos-latest]
+        os: [ubuntu-latest, windows-latest]
 
     runs-on: ${{ matrix.os }}