summaryrefslogtreecommitdiff
path: root/.github/workflows/test.yml
blob: 34f47429e2932ea4843d9c79068241a05fb04fbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: test

on:
  push:
  pull_request:

jobs:
  skip:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Skip job"

  before:
    runs-on: ubuntu-latest
    if: "! contains(github.event.head_commit.message, '[skip ci]')"
    steps:
      - run: echo "not contains '[skip ci]'"

  test:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os:
          - ubuntu-latest
          - macOS-latest
          - windows-latest
        nim_version:
          - '1.2.0'
          - 'stable'
    needs: before
    steps:
      - uses: actions/checkout@v1

      - name: Set cache-key
        id: vars
        run: |
          if [[ ${{ matrix.nim_version }} == stable ]]; then
            echo ::set-output name=cache-key::$(date +%Y-%m-%d)
          else
            echo ::set-output name=cache-key::${{ matrix.nim_version }}
          fi
        shell: bash

      - name: Print cache-key
        run: echo cache-key = ${{ steps.vars.outputs.cache-key }}

      - name: Cache choosenim
        id: cache-choosenim
        uses: actions/cache@v1
        with:
          path: ~/.choosenim
          key: ${{ runner.os }}-choosenim-${{ steps.vars.outputs.cache-key }}
      - name: Cache nimble
        id: cache-nimble
        uses: actions/cache@v1
        with:
          path: ~/.nimble
          key: ${{ runner.os }}-nimble-${{ hashFiles('*.nimble') }}
      - uses: jiro4989/setup-nim-action@v1
        with:
          nim-version: ${{ matrix.nim_version }}

      - name: Test examples
        run: |
          cd examples
          for file in $(ls -v example_*nim); do
            echo "=== test: $file ==="
            nim c "$file"
            echo ""
          done
        shell: bash