]> git.lizzy.rs Git - rust.git/blobdiff - .github/workflows/ci.yaml
Merge #7658
[rust.git] / .github / workflows / ci.yaml
index 02a3b622877e1d3f82c28fb556256f85eb284c53..1850068a340cdb7492bb4960f5b386e3cabc7505 100644 (file)
@@ -12,40 +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: Install Rust toolchain
-      uses: actions-rs/toolchain@v1
-      with:
-        toolchain: stable
-        profile: minimal
-        override: true
-
-    - name: Checkout repository
-      uses: actions/checkout@v2
-
-    - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
-
-    - name: Cache cargo
-      uses: actions/cache@v1
-      with:
-        path: ~/.cargo/
-        key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
-
-    - run: cargo install cargo-audit
-    - run: cargo audit
-
   rust:
     name: Rust
     runs-on: ${{ matrix.os }}
     env:
-     CC: deny_c
+      CC: deny_c
 
     strategy:
       fail-fast: false
@@ -55,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
@@ -64,6 +42,14 @@ jobs:
       if: matrix.os == 'windows-latest'
       run: Rename-Item C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc.old
 
+    # Work around https://github.com/actions/cache/issues/403 by using GNU tar
+    # instead of BSD tar.
+    - name: Install GNU tar
+      if: matrix.os == 'macos-latest'
+      run: |
+        brew install gnu-tar
+        echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
+
     - name: Install Rust toolchain
       uses: actions-rs/toolchain@v1
       with:
@@ -72,29 +58,22 @@ 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
+    - name: Cache cargo directories
+      uses: actions/cache@v2
       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') }}
+        path: |
+          ~/.cargo/registry
+          ~/.cargo/git
+        key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
 
     - name: Cache cargo target dir
-      uses: actions/cache@v1
+      uses: actions/cache@v2
       with:
         path: target
         key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
 
     - name: Compile
-      run: cargo test --no-run
+      run: cargo test --no-run --locked
 
     - name: Test
       run: cargo test
@@ -102,13 +81,51 @@ jobs:
     - 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 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
+
+    - name: Install Rust toolchain
+      uses: actions-rs/toolchain@v1
+      with:
+        toolchain: stable
+        profile: minimal
+        override: true
+
+    - name: Install Rust targets
+      run: rustup target add ${{ env.targets }}
+
+    - name: Cache cargo directories
+      uses: actions/cache@v2
+      with:
+        path: |
+          ~/.cargo/registry
+          ~/.cargo/git
+        key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
+
+    - name: Check
+      run: |
+        for target in ${{ env.targets }}; do
+          cargo check --target=$target --all-targets
+        done
 
   typescript:
     name: TypeScript
-    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest, windows-latest]
+
+    runs-on: ${{ matrix.os }}
+
     steps:
     - name: Checkout repository
       uses: actions/checkout@v2
@@ -121,11 +138,20 @@ jobs:
     - run: npm ci
       working-directory: ./editors/code
 
-    - run: npm audit || { sleep 10 && npm audit; } || { sleep 30 && npm audit; }
-      working-directory: ./editors/code
+#    - run: npm audit || { sleep 10 && npm audit; } || { sleep 30 && npm audit; }
+#      if: runner.os == 'Linux'
+#      working-directory: ./editors/code
 
     - run: npm run lint
       working-directory: ./editors/code
 
+    - name: Run vscode tests
+      uses: GabrielBB/xvfb-action@v1.2
+      env:
+        VSCODE_CLI: 1
+      with:
+        run: npm --prefix ./editors/code test
+        # working-directory: ./editors/code  # does not work: https://github.com/GabrielBB/xvfb-action/issues/8
+
     - run: npm run package --scripts-prepend-node-path
       working-directory: ./editors/code