|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + - dev |
| 11 | + paths-ignore: |
| 12 | + - 'webview-src/**' |
| 13 | + - 'webview-dist/**' |
| 14 | + - 'examples/**' |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-and-test: |
| 18 | + runs-on: ${{ matrix.os }} |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v2 |
| 26 | + |
| 27 | + - name: Install stable toolchain |
| 28 | + uses: actions-rs/toolchain@v1 |
| 29 | + with: |
| 30 | + toolchain: stable |
| 31 | + override: true |
| 32 | + |
| 33 | + - name: Install gtk on Ubuntu |
| 34 | + if: matrix.os == 'ubuntu-latest' |
| 35 | + run: | |
| 36 | + sudo apt-get update |
| 37 | + sudo apt-get install -y webkit2gtk-4.0 |
| 38 | + - name: Get current date |
| 39 | + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' |
| 40 | + run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV |
| 41 | + |
| 42 | + - name: Get current date |
| 43 | + if: matrix.os == 'windows-latest' |
| 44 | + run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 45 | + |
| 46 | + - name: Cache cargo registry |
| 47 | + uses: actions/cache@v2 |
| 48 | + with: |
| 49 | + path: ~/.cargo/registry |
| 50 | + # Add date to the cache to keep it up to date |
| 51 | + key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} |
| 52 | + # Restore from outdated cache for speed |
| 53 | + restore-keys: | |
| 54 | + ${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }} |
| 55 | +
|
| 56 | + - name: Cache cargo index |
| 57 | + uses: actions/cache@v2 |
| 58 | + with: |
| 59 | + path: ~/.cargo/git |
| 60 | + # Add date to the cache to keep it up to date |
| 61 | + key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} |
| 62 | + # Restore from outdated cache for speed |
| 63 | + restore-keys: | |
| 64 | + ${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }} |
| 65 | +
|
| 66 | + - name: Cache cargo target |
| 67 | + uses: actions/cache@v2 |
| 68 | + with: |
| 69 | + path: ${{ matrix.project}}/target |
| 70 | + # Add date to the cache to keep it up to date |
| 71 | + key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} |
| 72 | + # Restore from outdated cache for speed |
| 73 | + restore-keys: | |
| 74 | + ${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }} |
| 75 | +
|
| 76 | + - name: Run tests |
| 77 | + uses: actions-rs/cargo@v1 |
| 78 | + with: |
| 79 | + command: test |
| 80 | + args: --manifest-path=Cargo.toml --release |
0 commit comments