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

Print the branch names in dev builds #403

Merged
merged 8 commits into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
echo '* Running <run.sh>...'
echo "* Current working directory: $(pwd)"
echo "* Current node/npm versions: node $(node --version); npm $(npm --version)"
echo "* Current fe/be branches: $VITE_FE_BRANCH; $VITE_BE_BRANCH"

if [ ! -e node_modules ]; then
echo '* No node_modules/ dir found, installing dependencies...'
Expand Down
14 changes: 13 additions & 1 deletion simoc-web.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

IMGNAME = 'frontend-dev'
SIMOC_WEB_DIR = pathlib.Path(__file__).resolve().parent
# both dirs *should* have the same parent dir
SIMOC_DIR = SIMOC_WEB_DIR.parent / 'simoc'

COMMANDS = {}

Expand Down Expand Up @@ -40,7 +42,10 @@ def docker_run(*args):
cp = subprocess.run(['docker', 'network', 'inspect', net_name],
capture_output=True)
net_args = ['--network', net_name] if cp.returncode == 0 else []
fe_branch = f'VITE_FE_BRANCH={get_current_branch(SIMOC_WEB_DIR)}'
be_branch = f'VITE_BE_BRANCH={get_current_branch(SIMOC_DIR)}'
return run(['docker', 'run', '--rm', *net_args, '-p', '8080:8080',
'-e', fe_branch, '-e', be_branch,
'-v', f'{SIMOC_WEB_DIR}:/frontend', *args])

def install_docker():
Expand Down Expand Up @@ -68,6 +73,13 @@ def install_docker_linux():
print()
return False

def get_current_branch(dir):
branch_cmd = ['git', 'branch', '--show-current']
try:
return subprocess.check_output(branch_cmd, cwd=dir).decode().strip()
ezio-melotti marked this conversation as resolved.
Show resolved Hide resolved
except subprocess.CalledProcessError:
return 'unknown'

@cmd
def build_image():
"""Build the frontend-dev image locally."""
Expand Down Expand Up @@ -97,7 +109,7 @@ def build():
def copy_dist_dir():
"""Copy the dist dir into the "simoc" repo."""
# assume that both the simoc and simoc-web repos are in the same dir
simoc_server_dir = SIMOC_WEB_DIR.parent / 'simoc' / 'simoc_server'
simoc_server_dir = SIMOC_DIR / 'simoc_server'
simoc_web_dist_dir = SIMOC_WEB_DIR / 'dist'
if not simoc_server_dir.exists():
print(f'* <{simoc_server_dir}> does not exist')
Expand Down
17 changes: 16 additions & 1 deletion src/components/base/BaseEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,22 @@
EULA
</a>
</footer>
<div v-if="!is_ngs" id="branch">
{{env.MODE}} build
<template v-if="env.VITE_FE_BRANCH">/ fe: {{env.VITE_FE_BRANCH}}</template>
<template v-if="env.VITE_BE_BRANCH"> / be: {{env.VITE_BE_BRANCH}}</template>
</div>
</div>
</template>

<script>
export default {

data() {
return {
env: import.meta.env,
is_ngs: window.location.hostname.startsWith('ngs'),
}
},
}
</script>

Expand Down Expand Up @@ -159,6 +169,11 @@ export default {
justify-content:space-evenly;
align-items:center;
}
#branch {
margin-top: 1em;
color: #666666;
font-size: 80%;
}
</style>

<style lang="scss">
Expand Down