Update CI setup

This commit is contained in:
Abhilash Raj
2021-09-17 19:55:49 +00:00
committed by GitHub
parent 9fc4fbb12a
commit a5c591226d
5 changed files with 19 additions and 62 deletions

View File

@@ -1,7 +1,11 @@
version: '2' version: '2.1'
jobs: jobs:
build: build:
parameters:
rolling:
type: string
default: "no"
machine: machine:
image: ubuntu-2004:202010-01 image: ubuntu-2004:202010-01
docker_layer_caching: true docker_layer_caching: true
@@ -10,9 +14,6 @@ jobs:
BUILDKIT_PROGRESS: plain BUILDKIT_PROGRESS: plain
steps: steps:
- checkout - checkout
- run:
name: Setup Environment
command: source setup_env.sh
- run: - run:
name: Install Python dependencies name: Install Python dependencies
command: python3 -m pip install packaging command: python3 -m pip install packaging
@@ -21,7 +22,7 @@ jobs:
- python-deps-cache-v1 - python-deps-cache-v1
- run: - run:
name: Building Container Images name: Building Container Images
command: ./build.sh command: ./build.sh << parameters.rolling >>
- save_cache: - save_cache:
key: python-deps-cache-v1 key: python-deps-cache-v1
paths: paths:
@@ -48,6 +49,7 @@ workflows:
build-and-deploy-workflow: build-and-deploy-workflow:
jobs: jobs:
- build: - build:
rolling: "no"
filters: filters:
tags: tags:
only: /^v\d+\.\d+\.\d+$/ only: /^v\d+\.\d+\.\d+$/
@@ -61,11 +63,13 @@ workflows:
only: main only: main
jobs: jobs:
- build: - build:
rolling: "yes"
context: org-global context: org-global
rolling-workflow: rolling-workflow:
jobs: jobs:
- build: - build:
rolling: "yes"
context: org-global context: org-global
filters: filters:
branches: branches:

View File

@@ -2,16 +2,13 @@
set -ex set -ex
# Set the default value of BUILD_ROLLING to no.
export BUILD_ROLLING="${1:-no}"
DOCKER=docker DOCKER=docker
# Set the env variable to later test this release before it is deployed. if [ "$BUILD_ROLLING" = "yes" ]; then
if [ "$1" = "dev" ]; then echo "Building rolling releases..."
export DEV=true
fi
REG_URL=${REGISTRY}_URL
if [ "$EVENT_TYPE" = "cron" ] || [ "$DEV" = "true" ]; then
python3 -m venv venv python3 -m venv venv
source venv/bin/activate source venv/bin/activate
pip install python-gitlab pip install python-gitlab
@@ -46,6 +43,7 @@ if [ "$EVENT_TYPE" = "cron" ] || [ "$DEV" = "true" ]; then
--build-arg DJ_MM3_REF=$DJ_MM3_REF \ --build-arg DJ_MM3_REF=$DJ_MM3_REF \
-t maxking/mailman-web:rolling web/ -t maxking/mailman-web:rolling web/
# build the postorius image.
$DOCKER build -f postorius/Dockerfile.dev\ $DOCKER build -f postorius/Dockerfile.dev\
--label version.git_commit="$COMMIT_ID"\ --label version.git_commit="$COMMIT_ID"\
--label version.postorius="$POSTORIUS_REF" \ --label version.postorius="$POSTORIUS_REF" \
@@ -56,7 +54,8 @@ if [ "$EVENT_TYPE" = "cron" ] || [ "$DEV" = "true" ]; then
--build-arg DJ_MM3_REF=$DJ_MM3_REF \ --build-arg DJ_MM3_REF=$DJ_MM3_REF \
-t maxking/postorius:rolling postorius/ -t maxking/postorius:rolling postorius/
else else
# Do the normal building process. echo "Building stable releases..."
# Build the stable releases.
$DOCKER build -t maxking/mailman-core:rolling core/ $DOCKER build -t maxking/mailman-core:rolling core/
$DOCKER build -t maxking/mailman-web:rolling web/ $DOCKER build -t maxking/mailman-web:rolling web/
$DOCKER build -t maxking/postorius:rolling postorius/ $DOCKER build -t maxking/postorius:rolling postorius/

View File

@@ -34,6 +34,7 @@ USER = 'maxking'
TAG_VAR = 'CIRCLE_TAG' TAG_VAR = 'CIRCLE_TAG'
BRANCH_VAR = 'CIRCLE_BRANCH' BRANCH_VAR = 'CIRCLE_BRANCH'
PRIMARY_BRANCH = 'main' PRIMARY_BRANCH = 'main'
ROLLING_VAR = "BUILD_ROLLING"
def tag(original, final): def tag(original, final):
@@ -112,8 +113,7 @@ def main():
if img_tag.startswith('v'): if img_tag.startswith('v'):
img_tag = img_tag[1:] img_tag = img_tag[1:]
is_release = True is_release = True
elif os.environ.get(BRANCH_VAR) == PRIMARY_BRANCH and os.environ.get(ROLLING_VAR) == "yes":
elif os.environ.get(BRANCH_VAR) == PRIMARY_BRANCH:
img_tag = 'rolling' img_tag = 'rolling'
else: else:
print('Not running on {PRIMARY_BRANCH} branch or Git tag so not publishing...'.format( print('Not running on {PRIMARY_BRANCH} branch or Git tag so not publishing...'.format(

View File

@@ -1,38 +0,0 @@
# Script to setup environment variables.
set -ex
set_var () {
echo $1=$2 >> $BASH_ENV
export $1=$2
}
setup_env () {
CI_NAME=$1
# Set the current branch name.
BRANCH_NAME=${CI_NAME}_BRANCH
set_var BRANCH ${!BRANCH_NAME}
}
if [ "$TRAVIS" ]; then
# Set environments picked up from Circle CI.
set_var EVENT_TYPE "$TRAVIS_EVENT_TYPE"
set_var COMMIT_ID $TRAVIS_COMMIT
# Setup some generic environment vars.
setup_env TRAVIS
elif [ "$CIRCLECI" ]; then
# Set environments picked up from Circle CI.
set_var EVENT_TYPE "push"
set_var COMMIT_ID $CIRCLE_SHA1
# Setup some generic environment vars.
setup_env CIRCLE
fi
if [ "$BRANCH" = "master" ]; then
set_var TAG "latest"
else
set_var TAG "$COMMIT_ID"
fi
set_var REG_URL ${REGISTRY}_URL

View File

@@ -1,13 +1,5 @@
#!/bin/sh #!/bin/sh
if [ "$EVENT_TYPE" = "cron" ] || [ ! -z $DEV ] ; then
echo "Event type is: $EVENT_TYPE"
echo "This is a development version build: $DEV"
TAG="rolling"
fi
cat > docker-test.yaml <<EOF cat > docker-test.yaml <<EOF
version: '2' version: '2'