Skip to content

Commit

Permalink
Enable CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nhi-vanye committed Nov 1, 2023
1 parent 9d2012a commit 2d50fce
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 40 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Docker Image CI

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

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: ./scripts/build-image.sh -t "ci-${{github.sha}}"

2 changes: 0 additions & 2 deletions censere/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#
# Copyright (c) 2023 Richard Offer, All rights reserved.

from . import cmds

LOGGING = {
"version": 1,
"disable_existing_loggers": True,
Expand Down
14 changes: 7 additions & 7 deletions censere/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
import click

import os
#import sys
#import configobj
import pathlib
#import json
#import pydantic

import logging
import logging.config
Expand All @@ -27,6 +23,10 @@

cmd_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), "cmds"))

CONTEXT_SETTINGS = dict(
auto_envvar_prefix='CENSERE'
)

class CensereCLI(click.Group):
def list_commands(self, ctx):
rv = []
Expand All @@ -43,7 +43,7 @@ def get_command(self, ctx, name):
return
return mod.cli

@click.group(cls=CensereCLI, invoke_without_command=True)
@click.group(cls=CensereCLI, invoke_without_command=True, context_settings=CONTEXT_SETTINGS)
@click.pass_context
@click.option(
'--verbose',
Expand Down Expand Up @@ -127,7 +127,7 @@ def cli(ctx, verbose, debug, log_level, database, dump, debug_sql):
logging.getLogger( s[0] ).setLevel( s[1] )


if __name__ == '__main__':
#if __name__ == '__main__':

cli( obj=None , auto_envvar_prefix='CENSERE')
# cli( obj=None , auto_envvar_prefix='CENSERE')

31 changes: 31 additions & 0 deletions scripts/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#! /bin/sh

topdir=$( cd "$( dirname "$0" )/../" && pwd )

NAME=mars-censere

date=date

if [ "$(uname -s)" == "Darwin" ]; then
date=gdate
fi

# process the options

. ${topdir}/scripts/standard-args.sh
ParseArgs $*

if [ -n "${REGISTRY}" ]
then
PULL=--pull
fi

set -x
set -euo pipefail

echo docker buildx build --progress plain -o type=image -t ${NAME}:${TAG} .
exit 0
st=$?
docker image ls "${NAME}"
set +x
exit $st
26 changes: 2 additions & 24 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,15 @@ topdir=$( cd "$( dirname "$0" )/../" && pwd )

NAME=mars-censere

date=date

if [ "$(uname -s)" == "Darwin" ]; then
date=gdate
fi





# process the options

. ${topdir}/scripts/standard-args.sh
ParseArgs $*

if [ -n "${REGISTRY}" ]
then
PULL=--pull
fi

TAG=$(${date} +"${NAME}:%y.%m%d.%H%M")

set -x
set -euo pipefail
#docker pull ${NAME}:base || true
#docker pull ${NAME}:builder || true

docker buildx build --progress plain -o type=image -t ${TAG} .
python -m build
st=$?
docker image ls "${NAME}"
#docker push ${NAME}:base
#docker push ${NAME}:builder
ls -l dist
set +x
exit $st
7 changes: 0 additions & 7 deletions scripts/standard-args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,4 @@ EOF

shift $((OPTIND-1))

if [ -n "${PROJECT}" ]
then
TAG=${PROJECT}/${DIR}${TAG}:latest
else
TAG=${DIR}${TAG}:latest
fi

}

0 comments on commit 2d50fce

Please sign in to comment.