Skip to content

Commit

Permalink
Add CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
fishinthecalculator committed Sep 26, 2024
1 parent 4d2ba6a commit a9c578b
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Main branch

on:
push:
branches:
- "main"
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
contents: read

jobs:
test:

name: Build and test
runs-on: ubuntu-latest

steps:
- name: Run tests
uses: bonfire-networks/bonfire-extension-ci-action@latest
76 changes: 76 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# recipes for the `just` command runner: https://just.systems
# how to install: https://github.com/casey/just#packages

# we load all vars from .env file into the env of just commands
set dotenv-load
# and export just vars as env vars
set export

## Main configs - override these using env vars

APP_VSN_EXTRA := ""
DB_DOCKER_IMAGE := if arch() == "aarch64" { "ghcr.io/baosystems/postgis:12-3.3" } else { env_var_or_default('DB_DOCKER_IMAGE', "postgis/postgis:12-3.3-alpine") }
export MIX_ENV := "test"
export POSTGRES_PASSWORD := "postgres"

## Configure just
# choose shell for running recipes
set shell := ["bash", "-uc"]
# support args like $1, $2, etc, and $@ for all args
set positional-arguments


#### COMMANDS ####

help:
@echo "Just commands:"
@just --list

compile: deps-get
mix compile

clean:
mix deps.clean --all
rm -rf .hex .mix .cache lib/mix

deps-get:
mix deps.get

deps-update:
mix deps.update surface_form

common-mix-tasks-setup: deps-get
mkdir -p lib/mix/
cd lib/mix/ && (ln -sf ../../deps/bonfire_common/lib/mix_tasks tasks || ln -sf ../mix_tasks tasks) && cd -
cd lib/mix/tasks/release/ && MIX_ENV=prod mix escript.build && cd -

ext-migrations-copy: common-mix-tasks-setup
mkdir -p priv/repo
mix bonfire.extension.copy_migrations --to priv/repo/migrations --repo Bonfire.Common.Repo --force

run-tests:
mix test

test: start-test-db ext-migrations-copy create-test-db run-tests

create-test-db:
mix ecto.create -r Bonfire.Common.Repo

start-test-db:
docker run --name test-db -d -p "5432:5432" -e POSTGRES_PASSWORD --rm ${DB_DOCKER_IMAGE}

stop-test-db:
docker rm -f test-db

@release-increment: common-mix-tasks-setup
#!/usr/bin/env bash
set -euxo pipefail
export MIX_ENV="prod"
lib/mix/tasks/release/release ./ {{APP_VSN_EXTRA}}
release: release-increment
version="$(grep -E 'version: \"(.*)\",' mix.exs | sed -E 's/^.*version: \"(.*)\",$/\1/')"; git commit -m "Release v${version}" && git tag "v${version}"

push-release: release
git push
git push --tags

0 comments on commit a9c578b

Please sign in to comment.