Merge pull request #1517 from AmpersandTarski/feature/datamodel-only #1503
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired by https://tech.freckle.com/2021/05/18/haskell-on-actions/ | |
name: Build and test 🚀 | |
on: | |
push: | |
branches: | |
- "**" # Only trigger on branches (i.e. not tags, ..) | |
paths-ignore: | |
- "docs/**" # If only documentation changes, no need to build. | |
jobs: | |
build-and-test-docker: | |
name: Build with Docker | |
runs-on: ubuntu-22.04 | |
env: | |
DOCKER_AMPERSAND_IMAGE: ampersandtarski/ampersand | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Prepare for docker | |
run: | | |
echo Running on branch ${GITHUB_REF##*/} | |
docker version | |
- name: Build final image | |
run: docker build . --tag ${DOCKER_AMPERSAND_IMAGE}:latest --build-arg GIT_SHA=${{ github.sha }} --build-arg GIT_Branch=${{ github.ref }} | |
# For main branch push latest to DockerHub | |
- name: Login to DockerHub | |
if: github.ref == 'refs/heads/main' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Push latest | |
if: github.ref == 'refs/heads/main' | |
run: docker push ${DOCKER_AMPERSAND_IMAGE}:latest | |
build-and-test-ubuntu: | |
name: Build and test on ubuntu-22.04 🏗 🧪 | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout project contents 📡 | |
uses: actions/checkout@v4 | |
- name: Set up Mariadb 🧰 | |
uses: shogo82148/actions-setup-mysql@v1 | |
with: | |
mysql-version: "mariadb-11.5" | |
- name: Build and test 🏗 🧪 | |
uses: freckle/stack-action@v5 # stack-action does all these steps: dependencies, build, test. | |
with: | |
stack-build-arguments: "--copy-bins --flag ampersand:buildAll" | |
upgrade-stack: false | |
cache-save-always: true | |
build-and-test-macOS-13: | |
name: Build and test on macos-13 🏗 🧪 | |
runs-on: macos-13 | |
steps: | |
- name: Checkout project contents 📡 | |
uses: actions/checkout@v4 | |
- name: Set up Mariadb 🧰 | |
uses: shogo82148/actions-setup-mysql@v1 | |
with: | |
mysql-version: "mariadb-11.5" | |
# See issue https://github.com/freckle/stack-action/issues/80 for why we need to install stack and php as well | |
## run: curl -sSL https://get.haskellstack.org/ | sh | |
# - run: brew install php | |
- name: Build and test 🏗 🧪 | |
uses: freckle/stack-action@v5 | |
with: | |
stack-build-arguments: "--copy-bins --flag ampersand:buildAll" | |
test: false #Temporarily disable test because of bug in MariaDB with macOS. See https://jira.mariadb.org/browse/MDEV-35173 | |
build-and-test-windows: | |
name: Build and test on windows-2022 🏗 🧪 | |
runs-on: windows-2022 | |
steps: | |
- name: Checkout project contents 📡 | |
uses: actions/checkout@v4 | |
- name: Use cache (manually) 📦 # See https://github.com/freckle/stack-cache-action/issues/5 | |
uses: actions/cache@v4 | |
# TODO: Cache might be done better, see for inspiration: https://github.com/godu/advent-of-code-2020/blob/46796832f59d185457a8edf8de043a54a451d688/.github/workflows/ci.yml | |
with: | |
path: | | |
~/.ghc | |
~/.stack | |
~/.stack-work | |
key: ${{ runner.os }}-stack | |
- name: Set up Mariadb 🧰 | |
uses: shogo82148/actions-setup-mysql@v1 | |
with: | |
mysql-version: "mariadb-11.5" | |
- name: Setup PHP 🧰 | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: "8.0" | |
extensions: mysqli | |
- name: Build and test 🏗 🧪 | |
uses: freckle/stack-action@v5 | |
with: | |
stack-build-arguments: "--copy-bins --flag ampersand:buildAll" | |
upgrade-stack: false | |
cache-save-always: true |