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

Add CI. #5

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

Add CI. #5

wants to merge 7 commits into from

Conversation

fishinthecalculator
Copy link
Contributor

No description provided.

@fishinthecalculator fishinthecalculator marked this pull request as draft September 26, 2024 21:28
justfile Outdated
## 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") }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're now defaulting to a more recent version:

DB_DOCKER_VERSION := env_var_or_default('DB_DOCKER_VERSION', "16-3.4") 
DB_DOCKER_IMAGE := env_var_or_default('DB_DOCKER_IMAGE', if arch() == "aarch64" { "ghcr.io/baosystems/postgis:"+DB_DOCKER_VERSION } else { "postgis/postgis:"+DB_DOCKER_VERSION+"-alpine" })

Copy link
Contributor Author

@fishinthecalculator fishinthecalculator Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I'm preparing two template repositories if you think it makes sense. One for libraries and one for extensions, they contain "mainline" boilerplate for Bonfire QA (files like shared justfile, .github/workflows/ci.yml, .envrc and similar). I expect some extensions/libraries to deviate from the files tracked in the template boilerplate repositories but I would like to use these to document the common standard that should be expected across bonfire repositories, for example: to build libraries it is sufficient to run just deps-get && just compile, to run tests for extension docker is required and so on.

If we don't find a way to ship mess a Mix task I would add it as well to these repos, but I would like to think a little bit more about whether this could be implemented so I will not add it for now if you agree.

Do you think it would make sense? How could I call the two boilerplate repositories if it is worth doing in your opinion? I was thinking bonfire-extension-boilerplate and bonfire-library-boilerplate

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's an excellent idea!

In fact it could be used for more than manual reference as it could include a script used to update itself in a repo with a command like curl -sSL https://raw.githubusercontent.com/bonfire-networks/bonfire-extension-boilerplate/main/git_sync.sh | bash -s running a script like (untested LLM generated code):

#!/bin/bash

# Default values
DEFAULT_REMOTE_REPO="https://github.com/bonfire-networks/bonfire-extension-boilerplate.git"
DEFAULT_BRANCH_NAME="main"
SCRIPT_NAME=$(basename "$0")

# Use environment variables if set, otherwise use defaults
BF_TEMPLATE_GIT_REPO=${BF_TEMPLATE_GIT_REPO:-$DEFAULT_REMOTE_REPO}
BF_TEMPLATE_GIT_BRANCH=${BF_TEMPLATE_GIT_BRANCH:-$DEFAULT_BRANCH_NAME}
BF_TEMPLATE_GIT_DIR=${BF_TEMPLATE_GIT_DIR:-$(mktemp -d)}

echo "Using repository: $BF_TEMPLATE_GIT_REPO"
echo "Using branch: $BF_TEMPLATE_GIT_BRANCH"
echo "Using temporary directory: $BF_TEMPLATE_GIT_DIR"

# Function to clone or update the repository
clone_or_update_repo() {
    if [ -d "$BF_TEMPLATE_GIT_DIR/.git" ]; then
        echo "Repository already exists. Updating..."
        cd "$BF_TEMPLATE_GIT_DIR"
        git fetch --depth 1 origin "$BF_TEMPLATE_GIT_BRANCH"
        git reset --hard FETCH_HEAD
        git clean -fd
        cd - > /dev/null
    else
        echo "Cloning repository..."
        git clone --depth 1 --branch "$BF_TEMPLATE_GIT_BRANCH" "$BF_TEMPLATE_GIT_REPO" "$BF_TEMPLATE_GIT_DIR"
    fi

    if [ $? -ne 0 ]; then
        echo "Failed to clone or update the repository. Please check the repository URL and branch name."
        exit 1
    fi
}

# Clone or update the repository
clone_or_update_repo

# Copy files from temporary directory to current directory, excluding .git and this script
rsync -av --delete --exclude='.git' --exclude="$SCRIPT_NAME" "$BF_TEMPLATE_GIT_DIR/" ./

echo "Sync completed successfully."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we want something similar in libraries though, since those are meant to be bonfire-agnostic?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of adding mess, makes sense to me, especially if we're able to easily pull in any changes this way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fishinthecalculator what did you think of the possibility of adding a "self update" command to the justfile, so it can update itself + mess from a canonical repo?

Copy link
Member

@mayel mayel Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would be much simpler than wrangly elixir/mix to make mess a dependency, and have the advantage of also keeping extensions' justfile up-to-date and maybe also CI specs (and any other files we may need to add in future)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants