Skip to content

[WIP] Add update.py semi-automatic release crawler #1

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

Merged
merged 14 commits into from
Jan 4, 2023
Merged
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
59 changes: 36 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,66 @@
---
tag_filter: &tag_filter
filters:
tags:
only: /.*/
branches:
ignore: /.*/

version: 2.1

jobs:

build:
machine:
# https://circleci.com/developer/machine/image/ubuntu-2204
image: ubuntu-2204:2022.10.2
steps:
- checkout
- restore_cache:
keys:
- my_cache
- run:
name: Build Docker image
command: |
wget https://raw.githubusercontent.com/bids-apps/maintenance-tools/main/circleci/build_docker.sh
bash build_docker.sh
- save_cache:
key: my_cache
paths:
- ~/docker
command: bash build_docker.sh
no_output_timeout: 30m # MCR is a large download
- persist_to_workspace:
root: /home/circleci
paths:
- docker/image.tar

deploy:
test:
machine:
image: ubuntu-2204:2022.10.2
steps:
- attach_workspace:
at: /tmp/workspace
- run: docker load -i /tmp/workspace/image.tar
- run:
name: push to dockerhub
name: Test Docker image
command: |
wget https://raw.githubusercontent.com/bids-apps/maintenance-tools/main/circleci/push_docker.sh
bash push_docker.sh
docker load -i /tmp/workspace/docker/image.tar
# figure out a better test
docker run -ti --rm --read-only \
--entrypoint /bin/sh bids/${CIRCLE_PROJECT_REPONAME,,} \
-c 'test -d ${MCR_HOME}/runtime/glnxa64'

deploy:
docker:
- image: circleci/buildpack-deps:stretch
steps:
- attach_workspace:
at: /tmp/workspace
- setup_remote_docker
- run: docker load -i /tmp/workspace/docker/image.tar
- run:
name: Publish Docker image
command: push_docker.sh

workflows:
build-test-deploy:
jobs:
- build
- deploy:
- build:
<<: *tag_filter
- test:
requires:
- build
filters:
tags:
only: /.*/

# VS Code Extension Version: 1.5.1
<<: *tag_filter
- deploy:
requires:
- test
<<: *tag_filter
2 changes: 2 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
ignored:
- DL3003
- DL3006
- DL3008
- SC2086
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,27 @@ repos:
types: [dockerfile]
entry: ghcr.io/hadolint/hadolint hadolint

- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8

- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
hooks:
- id: reorder-python-imports
args: [--py38-plus]

ci:
skip: [hadolint-docker]
25 changes: 0 additions & 25 deletions Dockerfile

This file was deleted.

11 changes: 11 additions & 0 deletions build_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /bin/bash

# used to build the Docker image for a project in circle CI

git describe --tags --always > version
docker build -t "bids/${CIRCLE_PROJECT_REPONAME,,}" .
mkdir -p ${HOME}/docker
docker save "bids/${CIRCLE_PROJECT_REPONAME,,}" > ~/docker/image.tar
# persist guessed branch so we can use it in deploy/tag
BRANCH=$(git branch --contains tags/${CIRCLE_TAG})
echo -n "${BRANCH}" > ~/docker/branch
25 changes: 25 additions & 0 deletions push_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#! /bin/bash

# used to push the Docker image for a project in circle CI

if [[ -n "${CIRCLE_TAG}" ]]; then

echo "${DOCKER_PASS}" | docker login --username "${DOCKER_USER}" --password-stdin

# tag should always be X.Y.Z[-variant]
docker tag "bids/${CIRCLE_PROJECT_REPONAME,,}" "bids/${CIRCLE_PROJECT_REPONAME,,}:${CIRCLE_TAG}"
docker push "bids/${CIRCLE_PROJECT_REPONAME,,}:${CIRCLE_TAG}"

# also publish tag for the corresponding matlab release version, which is the name of the current branch
docker "tag bids/${CIRCLE_PROJECT_REPONAME,,}" "bids/${CIRCLE_PROJECT_REPONAME,,}:${BRANCH}"
docker push "bids/${CIRCLE_PROJECT_REPONAME,,}:${BRANCH}"
BRANCH=$(cat /tmp/workspace/docker/branch)

# update major tag X.Y[-variant] to the latest in this branch
MAJOR_TAG=$(echo "${CIRCLE_TAG}" | sed -rn 's#([[:digit:]]+).([[:digit:]]+).([[:digit:]]+)(.*)#\1.\2\4#p')
if [[ -n "${MAJOR_TAG}" ]] ; then
docker tag "bids/${CIRCLE_PROJECT_REPONAME,,}" "bids/${CIRCLE_PROJECT_REPONAME,,}:${MAJOR_TAG}"
docker push "bids/${CIRCLE_PROJECT_REPONAME,,}:${MAJOR_TAG}"
fi

fi
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rich
beautifulsoup4
packaging
chevron
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 100
48 changes: 48 additions & 0 deletions template.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM bids/base_validator

# Update system
RUN apt-get -qq update -qq && \
apt-get -qq install -qq -y --no-install-recommends \
unzip \
xorg \
wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install MATLAB MCR
ENV MATLAB_VERSION {{ MATLAB_VERSION }}
RUN mkdir /opt/mcr_install && \
mkdir /opt/mcr && \
wget --quiet -P /opt/mcr_install {{ MCR_LINK }} && \
unzip -q /opt/mcr_install/*${MATLAB_VERSION}*.zip -d /opt/mcr_install && \
cd /opt/mcr_install && mkdir save && \
{{#core_only}}
for f in $(grep -E '(xml|enc)$' productdata/1000.txt) ; do cp --parents archives/$f save/ ; done && \
for f in $(grep -E '(xml|enc)$' productdata/35000.txt) ; do cp --parents archives/$f save/ ; done && \
for f in $(grep -E '(xml|enc)$' productdata/35010.txt) ; do cp --parents archives/$f save/ ; done && \
rm -rf archives && mv save/archives . && rmdir save && \
{{/core_only}}
/opt/mcr_install/install -destinationFolder /opt/mcr -agreeToLicense yes -mode silent && \
{{#core_only}}
rm -rf /opt/mcr/*/cefclient && \
rm -rf /opt/mcr/*/mcr/toolbox/matlab/maps && \
rm -rf /opt/mcr/*/java/jarext && \
rm -rf /opt/mcr/*/toolbox/matlab/system/editor && \
rm -rf /opt/mcr/*/toolbox/matlab/codetools && \
rm -rf /opt/mcr/*/toolbox/matlab/datatools && \
rm -rf /opt/mcr/*/toolbox/matlab/codeanalysis && \
rm -rf /opt/mcr/*/toolbox/shared/dastudio && \
rm -rf /opt/mcr/*/toolbox/shared/mlreportgen && \
rm -rf /opt/mcr/*/sys/java/jre/glnxa64/jre/lib/ext/jfxrt.jar && \
rm -rf /opt/mcr/*/sys/java/jre/glnxa64/jre/lib/amd64/libjfxwebkit.so && \
rm -rf /opt/mcr/*/bin/glnxa64/libQt* && \
rm -rf /opt/mcr/*/bin/glnxa64/qtwebengine && \
rm -rf /opt/mcr/*/bin/glnxa64/cef_resources && \
{{/core_only}}
rm -rf /opt/mcr_install /tmp/*

# Configure environment
ENV MCR_VERSION {{ MCR_VERSION }}
ENV LD_LIBRARY_PATH /opt/mcr/${MCR_VERSION}/runtime/glnxa64:/opt/mcr/${MCR_VERSION}/bin/glnxa64:/opt/mcr/${MCR_VERSION}/sys/os/glnxa64:/opt/mcr/${MCR_VERSION}/sys/opengl/lib/glnxa64
ENV MCR_INHIBIT_CTF_LOCK 1
ENV MCR_HOME /opt/mcr/${MCR_VERSION}
Loading