aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/CI.yml
blob: 83f4fc499cfaf03d3ab56b296ad12451374cca76 (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
72
73
74
name: CI

on: [push, pull_request]

env:
  CI: "ON" # We can detect this in the build system and other vendors implement it
  CMAKE_BUILD_PARALLEL_LEVEL: "2" # 2 cores on each GHA VM, enable parallel builds
  CTEST_OUTPUT_ON_FAILURE: "ON" # This way we don't need a flag to ctest
  CTEST_PARALLEL_LEVEL: "2"
  HOMEBREW_NO_ANALYTICS: "ON" # Make Homebrew installation a little quicker
  HOMEBREW_NO_AUTO_UPDATE: "ON"
  HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: "ON"
  HOMEBREW_NO_GITHUB_API: "ON"
  HOMEBREW_NO_INSTALL_CLEANUP: "ON"

jobs:
  Build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]
        gcc_v: [9] # Version of GFortran we want to use.
    env:
      FC: gfortran-${{ matrix.gcc_v }}
      GCC_V: ${{ matrix.gcc_v }}

    steps:
    - name: Checkout code
      uses: actions/checkout@v1

    - name: Set up Python 3.x
      uses: actions/setup-python@v1 # Use pip to install latest CMake, & FORD/Jin2For, etc.
      with:
        python-version: 3.x

    - name: Set up common
      run: pip install --upgrade cmake

    - name: Install GFortran Linux
      if: contains(matrix.os, 'ubuntu')
      run: |
        sudo add-apt-repository ppa:ubuntu-toolchain-r/test
        sudo apt-get update
        sudo apt-get install -y gcc-${GCC_V} gfortran-${GCC_V}
        sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
        --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
        --slave /usr/bingcov gcov /usr/bin/gcov-${GCC_V}

    - name: Install GFortran macOS
      if: contains( matrix.os, 'macos')
      run: brew install gcc@${GCC_V} || brew upgrade gcc@${GCC_V} || true

    - name: Install Rust macOS
      if: contains(matrix.os, 'macos')
      run: |
        curl https://sh.rustup.rs -sSf | sh -s -- -y

    - name: Build
      run: |
        export PATH="$HOME/.cargo/bin:$PATH"
        cargo build --verbose

    - name: Run tests
      run: |
        export PATH="$HOME/.cargo/bin:$PATH"
        cargo test --verbose

    # TODO: integrate these with `cargo test` above
    - name: Run manual tests
      run: |
        export PATH="$HOME/.cargo/bin:$PATH"
        cargo run -- --help
        ./run_tests.sh