Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci #1

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Ci #1

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if has guix; then
use guix erlang elixir elixir-hex just
fi
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Main branch

on:
push:
branches:
- "main"
pull_request:
branches: [ "main" ]

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
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release

on:
push:
tags:
- 'v*.*.*'

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Run tests
uses: bonfire-networks/bonfire-extension-ci-action@latest

- name: Github Release
uses: ncipollo/release-action@v1

- name: Publish to Hex.pm
uses: erlangpack/github-action@v3
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ deps.path
.\#*

assets/js/_hooks/
assets/css
assets/css

# Mix tasks
lib/mix

# Migrations
priv/repo/migrations/*.exs
5 changes: 5 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Config


IO.puts("Load runtime config...")
Bonfire.Common.Config.LoadExtensionsConfig.load_configs(Bonfire.Common.RuntimeConfig)
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 --all

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
4 changes: 2 additions & 2 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
IO.puts("Prepare to run tests...")

IO.puts("Start app...")
Application.ensure_all_started(:bonfire)

IO.puts("Prepare to run tests...")
Code.ensure_loaded!(Bonfire.Testing)
Bonfire.Testing.configure_start_test()
Loading