|
| 1 | +name: "Continuous Integration" |
| 2 | +on: [push] |
| 3 | + |
| 4 | +jobs: |
| 5 | + test: |
| 6 | + name: "Test" |
| 7 | + strategy: |
| 8 | + matrix: |
| 9 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 10 | + runs-on: "${{ matrix.os }}" |
| 11 | + steps: |
| 12 | + # Check out the code |
| 13 | + - uses: "actions/checkout@v2" |
| 14 | + |
| 15 | + # We need node for some integration tests |
| 16 | + - uses: "actions/setup-node@v1" |
| 17 | + |
| 18 | + # Set the current month and year (used for cache key) |
| 19 | + - name: "Get Date" |
| 20 | + id: get-date |
| 21 | + # Outputs e.g. "202007" |
| 22 | + # tbh I have yet to find the docs where this output format is |
| 23 | + # defined, but I copied this from the official cache action's README. |
| 24 | + run: | |
| 25 | + echo "::set-output name=date::$(/bin/date -u '+%Y%m')" |
| 26 | + shell: bash |
| 27 | + |
| 28 | + # Generate the lockfile |
| 29 | + - name: "Generate Cargo Lockfile" |
| 30 | + run: "cargo generate-lockfile" |
| 31 | + |
| 32 | + # Cache build dependencies |
| 33 | + - name: "Cache Build Fragments" |
| 34 | + id: "cache-build-fragments" |
| 35 | + uses: "actions/cache@v2" |
| 36 | + with: |
| 37 | + path: | |
| 38 | + ~/.cargo/registry |
| 39 | + ~/.cargo/git |
| 40 | + target |
| 41 | + # Rebuild whenever the cargo lock file changes |
| 42 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 43 | + |
| 44 | + # Cache `cargo install` built binaries |
| 45 | + - name: "Cache Built Binaries" |
| 46 | + id: "cache-binaries" |
| 47 | + uses: "actions/cache@v2" |
| 48 | + with: |
| 49 | + path: "~/.cargo/bin" |
| 50 | + # In theory, this should rebuild binaries once a month |
| 51 | + key: "${{ runner.os }}-cargo-binaries-${{steps.get-date.outputs.date}}" |
| 52 | + |
| 53 | + # Ensure we're all set up |
| 54 | + - name: "Perform Setup" |
| 55 | + run: "make setup" |
| 56 | + |
| 57 | + # Run the tests |
| 58 | + - name: "Run Tests" |
| 59 | + run: "make test" |
0 commit comments