|
| 1 | +name: Build and test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + schedule: |
| 7 | + # run daily, this refreshes the cache |
| 8 | + - cron: '30 4 * * *' |
| 9 | + |
| 10 | +jobs: |
| 11 | + ocaml-test: |
| 12 | + name: Ocaml tests |
| 13 | + runs-on: ubuntu-20.04 |
| 14 | + env: |
| 15 | + package: "xapi-networkd" |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v2 |
| 20 | + |
| 21 | + - name: Pull configuration from xs-opam |
| 22 | + run: | |
| 23 | + curl --fail --silent https://raw.githubusercontent.com/xapi-project/xs-opam/master/tools/xs-opam-ci.env | cut -f2 -d " " > .env |
| 24 | +
|
| 25 | + - name: Load environment file |
| 26 | + id: dotenv |
| 27 | + |
| 28 | + |
| 29 | + - name: Retrieve date for cache key |
| 30 | + id: cache-key |
| 31 | + run: echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")" |
| 32 | + shell: bash |
| 33 | + |
| 34 | + - name: Restore opam cache |
| 35 | + id: opam-cache |
| 36 | + uses: actions/cache@v2 |
| 37 | + with: |
| 38 | + path: "~/.opam" |
| 39 | + # invalidate cache daily, gets built daily using a scheduled job |
| 40 | + key: ${{ steps.cache-key.outputs.date }} |
| 41 | + |
| 42 | + - name: Use ocaml |
| 43 | + uses: avsm/setup-ocaml@v1 |
| 44 | + with: |
| 45 | + ocaml-version: ${{ steps.dotenv.outputs.ocaml_version_full }} |
| 46 | + opam-repository: ${{ steps.dotenv.outputs.repository }} |
| 47 | + |
| 48 | + - name: Update opam metadata |
| 49 | + run: | |
| 50 | + opam update |
| 51 | + opam pin add . --no-action |
| 52 | +
|
| 53 | + - name: Install external dependencies |
| 54 | + run: opam depext -u ${{ env.package }} |
| 55 | + |
| 56 | + - name: Install dependencies |
| 57 | + run: | |
| 58 | + opam upgrade |
| 59 | + opam install ${{ env.package }} --deps-only --with-test -v |
| 60 | +
|
| 61 | + - name: Build |
| 62 | + run: opam exec -- make |
| 63 | + |
| 64 | + - name: Run tests |
| 65 | + run: opam exec -- make test |
| 66 | + |
| 67 | + - name: Uninstall unversioned packages |
| 68 | + # This should purge them from the cache, unversioned package have |
| 69 | + # 'master' as its version |
| 70 | + run: opam list | awk -F " " '$2 == "master" { print $1 }' | xargs opam uninstall |
0 commit comments