This is an automated email from the ASF dual-hosted git repository.

nchung pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-nexus.git


The following commit(s) were added to refs/heads/develop by this push:
     new 6e04be5  SDAP-162 - Create build for nexus-webapp (#140)
6e04be5 is described below

commit 6e04be57b5cb39ad389dab29d5e1ad1e3015eb11
Author: joshgarde <[email protected]>
AuthorDate: Mon Nov 1 16:14:20 2021 -0700

    SDAP-162 - Create build for nexus-webapp (#140)
    
    * Standardize versions
    
    * Read version from file
    
    * Initial GH Actions work
    
    * Lint version.py
    
    * Add openapi spec to versioning
    
    * Simplify multi-file version tracking
    
    * Bump openapi version + change tracking to follow Docker
    
    * Update username reference
---
 .github/workflows/build.yaml            | 132 ++++++++++++++++++++++++++++
 .github/workflows/version.py            |  92 ++++++++++++++++++++
 analysis/VERSION.txt                    |   1 +
 analysis/setup.py                       |   3 +-
 analysis/webservice/apidocs/openapi.yml |   2 +-
 data-access/VERSION.txt                 |   1 +
 data-access/setup.py                    |   3 +-
 docker/nexus-webapp/VERSION.txt         |   1 +
 environment.yml                         | 147 ++++++++++++++++++++++++++++++++
 9 files changed, 379 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
new file mode 100644
index 0000000..527d212
--- /dev/null
+++ b/.github/workflows/build.yaml
@@ -0,0 +1,132 @@
+name: build
+on: push
+jobs:
+  build:
+    name: Build, Test, Verify, Publish
+    runs-on: ubuntu-latest
+    steps:
+    - name: Checkout sdap-nexus
+      uses: actions/checkout@v2
+      with:
+        fetch-depth: 0
+    - name: Install miniconda
+      run: |
+        curl -o /tmp/miniconda.sh 
"https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh";
+        bash /tmp/miniconda.sh -b -p /opt/miniconda
+        echo "/opt/miniconda/condabin" >> $GITHUB_PATH  # Preserve conda's 
PATH across jobs
+        /opt/miniconda/condabin/conda init bash
+    - name: Setup dependencies
+      run: |
+        conda config --add channels conda-forge
+        conda config --set channel_priority strict
+        conda env create -qf environment.yml
+    - name: Install analysis & data-access
+      shell: bash -ieo pipefail {0} # Interative shells required for conda
+      run: |
+        conda activate sdap-nexus
+        pip install -q analysis
+        pip install -q data-access
+    - name: Install pipeline tools
+      shell: bash -ieo pipefail {0}
+      run: |
+        conda activate sdap-nexus
+        conda install -qy pylint flake8 pytest
+    - name: Lint
+      shell: bash -ieo pipefail {0}
+      continue-on-error: true
+      run: |
+        conda activate sdap-nexus
+        pylint analysis
+        flake8 analysis
+        pylint data-access
+        flake8 data-access
+    - name: Test and coverage
+      continue-on-error: true
+      shell: bash -ieo pipefail {0}
+      run: |
+        conda activate sdap-nexus
+        pytest analysis/tests/
+        pytest data-access/tests/
+    - name: Get module commits relative to develop
+      if: ${{ github.ref != 'refs/heads/develop' && github.ref != 
'refs/heads/master' }}
+      run: |
+        echo "BRANCH=origin/develop" >> $GITHUB_ENV
+    - name: Get module commits relative to master
+      if: ${{ github.ref == 'refs/heads/develop' }}
+      run: |
+        echo "BRANCH=origin/master" >> $GITHUB_ENV
+    - name: Get module commits relative to latest tag
+      if: ${{ github.ref == 'refs/heads/master' }}
+      run: |
+        echo "BRANCH=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
+    - name: Get module commits
+      id: get_module_commits
+      run: |
+        DATA_ACCESS_COMMITS=$(git rev-list $BRANCH -- data-access| wc -l | awk 
'{print $1}')
+        ANALYSIS_COMMITS=$(git rev-list $BRANCH -- analysis| wc -l | awk 
'{print $1}')
+
+        echo "data-access commits: $DATA_ACCESS_COMMITS"
+        echo "analysis commits: $ANALYSIS_COMMITS"
+
+        echo "::set-output name=data_access_commits::$DATA_ACCESS_COMMITS"
+        echo "::set-output name=analysis_commits::$ANALYSIS_COMMITS"
+    - name: Bump pre-alpha version
+      if: ${{ github.ref != 'refs/heads/develop' && github.ref != 
'refs/heads/master' }}
+      run: |
+        echo "PHASE=pre-alpha" >> $GITHUB_ENV
+        echo "VALUE=$(git rev-parse --short ${GITHUB_SHA})" >> $GITHUB_ENV
+    - name: Bump alpha version
+      if: ${{ github.ref == 'refs/heads/develop' }}
+      run: |
+        echo "PHASE=alpha" >> $GITHUB_ENV
+        echo "VALUE=auto" >> $GITHUB_ENV
+    - name: Bump release version
+      if: ${{ github.ref == 'refs/heads/master' }}
+      run: |
+        echo "PHASE=patch" >> $GITHUB_ENV
+        echo "VALUE=auto" >> $GITHUB_ENV
+    - name: Bump versions
+      id: bump_versions
+      run: |
+        if [ ${{steps.get_module_commits.outputs.data_access_commits}} -gt 0 
]; then
+          DATA_ACCESS_VERSION=$(python3 .github/workflows/version.py 
data-access/VERSION.txt --phase $PHASE --value $VALUE)
+        else
+          DATA_ACCESS_VERSION=$(python3 .github/workflows/version.py 
data-access/VERSION.txt)
+        fi
+        if [ ${{steps.get_module_commits.outputs.analysis_commits}} -gt 0 ]; 
then
+          ANALYSIS_VERSION=$(python3 .github/workflows/version.py 
analysis/VERSION.txt --phase $PHASE --value $VALUE)
+        else
+          ANALYSIS_VERSION=$(python3 .github/workflows/version.py 
analysis/VERSION.txt)
+        fi
+        DOCKER_VERSION=$(python3 .github/workflows/version.py 
docker/nexus-webapp/VERSION.txt --phase $PHASE --value $VALUE --track 
analysis/webservice/apidocs/openapi.yml)
+        echo "data-access: $DATA_ACCESS_VERSION"
+        echo "analysis: $ANALYSIS_VERSION"
+        echo "docker: $DOCKER_VERSION"
+
+        echo "::set-output name=data_access_version::$DATA_ACCESS_VERSION"
+        echo "::set-output name=analysis_version::$ANALYSIS_VERSION"
+        echo "::set-output name=docker_version::$DOCKER_VERSION"
+    - name: Commit version bump + tag
+      if: |
+        github.ref == 'refs/heads/develop' ||
+        github.ref == 'refs/heads/master'    ||
+        startsWith(github.ref, 'refs/heads/release')
+      run: |
+        git config --global user.name 'sdap-nexus bot'
+        git config --global user.email '[email protected]'
+        git commit -am "/version 
${{steps.bump_versions.outputs.docker_version}}"
+        git tag -a 
"distributed.${{steps.bump_versions.outputs.docker_version}}" -m "Version 
${{steps.bump_versions.outputs.docker_version}}"
+        git push origin
+        git push origin 
"distributed.${{steps.bump_versions.outputs.docker_version}}"
+    - name: Log in to the Container registry
+      uses: docker/login-action@v1
+      with:
+        username: ${{ secrets.DOCKERHUB_USER }}
+        password: ${{ secrets.DOCKERHUB_TOKEN }}
+    - name: Build and push Docker image
+      id: docker_build
+      uses: docker/build-push-action@v2
+      with:
+        push: true
+        file: 'docker/nexus-webapp/Dockerfile'
+        tags: nexusjpl/nexus-webapp:distributed.${{ 
steps.bump_versions.outputs.docker_version }}
diff --git a/.github/workflows/version.py b/.github/workflows/version.py
new file mode 100755
index 0000000..81c65f5
--- /dev/null
+++ b/.github/workflows/version.py
@@ -0,0 +1,92 @@
+#!/usr/bin/env python3
+from argparse import ArgumentParser
+import re
+
+version_regex = re.compile(
+    
r'(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((a(?P<alpha_num>\d+))|(-(?P<commit>.*)))?'
  # noqa: E501
+)
+
+
+def main():
+    parser = ArgumentParser()
+    parser.add_argument('file')
+    parser.add_argument('--phase', default='current')
+    parser.add_argument('--value', default='auto')
+    parser.add_argument('--track', nargs='+', default=[])
+
+    args = parser.parse_args()
+
+    version_file = open(args.file, 'r+')
+    version_contents = version_file.read()
+
+    current_version = version_regex.search(version_contents)
+    if current_version is None:
+        print('Version not found in file')
+        exit(1)
+
+    if args.phase == 'current':
+        print(current_version.group(0))
+        version_file.close()
+        return
+
+    new_version = bump_version(current_version, args.phase, args.value)
+    version_contents = version_regex.sub(
+        new_version, version_contents, count=1)
+
+    print(new_version)
+
+    version_file.seek(0)
+    version_file.write(version_contents)
+    version_file.truncate()
+    version_file.close()
+
+    for tracked_path in args.track:
+        with open(tracked_path, 'r+') as tracked_file:
+            contents = tracked_file.read()
+            new_contents = contents.replace(
+                current_version.group(0), new_version, 1)
+
+            tracked_file.seek(0)
+            tracked_file.write(new_contents)
+            tracked_file.truncate()
+
+
+def bump_version(version, phase, value):
+    major = int(version.group('major'))
+    minor = int(version.group('minor'))
+    patch = int(version.group('patch'))
+
+    if phase == 'manual':
+        if value == 'auto':
+            raise Exception('value cannot be auto on manual')
+
+        return value
+    elif phase == 'pre-alpha':
+        if value == 'auto':
+            raise Exception('value cannot be auto on pre-alpha')
+
+        return f'{major}.{minor}.{patch}-{value}'
+    elif phase == 'alpha':
+        alpha_num = version.group('alpha_num')
+        alpha_num = 0 if alpha_num is None else int(alpha_num) + 1
+
+        return f'{major}.{minor}.{patch}a{alpha_num}'
+    elif phase == 'patch':
+        patch = patch + 1 if value == 'auto' else value
+
+        return f'{major}.{minor}.{patch}'
+    elif phase == 'minor':
+        minor = minor + 1 if value == 'auto' else value
+        patch = 0
+
+        return f'{major}.{minor}.{patch}'
+    elif phase == 'major':
+        major = major + 1 if value == 'auto' else value
+        minor = 0
+        patch = 0
+
+        return f'{major}.{minor}.{patch}'
+
+
+if __name__ == '__main__':
+    main()
diff --git a/analysis/VERSION.txt b/analysis/VERSION.txt
new file mode 100644
index 0000000..ce6a70b
--- /dev/null
+++ b/analysis/VERSION.txt
@@ -0,0 +1 @@
+1.6.0
\ No newline at end of file
diff --git a/analysis/setup.py b/analysis/setup.py
index 3eced72..9a4d880 100644
--- a/analysis/setup.py
+++ b/analysis/setup.py
@@ -17,7 +17,8 @@
 import setuptools
 from subprocess import check_call, CalledProcessError
 
-__version__ = '1.6'
+with open('VERSION.txt', 'r') as f:
+    __version__ = f.read()
 
 
 try:
diff --git a/analysis/webservice/apidocs/openapi.yml 
b/analysis/webservice/apidocs/openapi.yml
index 773814f..2ea63a5 100644
--- a/analysis/webservice/apidocs/openapi.yml
+++ b/analysis/webservice/apidocs/openapi.yml
@@ -1,7 +1,7 @@
 openapi: 3.0.3
 info:
   description: The next generation cloud-based science data service platform.
-  version: 0.4.2
+  version: 0.4.5a29
   title: Distributed Oceanographic Matchup Service (DOMS)
   license:
     name: Apache 2.0
diff --git a/data-access/VERSION.txt b/data-access/VERSION.txt
new file mode 100644
index 0000000..7d07a19
--- /dev/null
+++ b/data-access/VERSION.txt
@@ -0,0 +1 @@
+0.33.0
\ No newline at end of file
diff --git a/data-access/setup.py b/data-access/setup.py
index 66a9933..d65d490 100644
--- a/data-access/setup.py
+++ b/data-access/setup.py
@@ -15,7 +15,8 @@
 
 from setuptools import setup
 
-__version__ = '0.33'
+with open('VERSION.txt', 'r') as f:
+    __version__ = f.read()
 
 
 with open('requirements.txt') as f:
diff --git a/docker/nexus-webapp/VERSION.txt b/docker/nexus-webapp/VERSION.txt
new file mode 100644
index 0000000..d452e80
--- /dev/null
+++ b/docker/nexus-webapp/VERSION.txt
@@ -0,0 +1 @@
+0.4.5a29
\ No newline at end of file
diff --git a/environment.yml b/environment.yml
new file mode 100644
index 0000000..8186104
--- /dev/null
+++ b/environment.yml
@@ -0,0 +1,147 @@
+name: sdap-nexus
+channels:
+  - conda-forge
+  - defaults
+dependencies:
+  - abseil-cpp=20210324.1
+  - arrow-cpp=4.0.0
+  - aws-c-cal=0.5.10
+  - aws-c-common=0.5.11
+  - aws-c-event-stream=0.2.7
+  - aws-c-io=0.10.2
+  - aws-checksums=0.1.11
+  - aws-sdk-cpp=1.8.186
+  - backports=1.0
+  - backports.functools_lru_cache=1.6.1
+  - basemap=1.2.2
+  - boost-cpp=1.74.0
+  - boto3=1.16.63
+  - botocore=1.19.63
+  - brotli=1.0.9
+  - brotli-bin=1.0.9
+  - brotlipy=0.7.0
+  - bzip2=1.0.8
+  - c-ares=1.17.2
+  - ca-certificates=2021.5.30
+  - cairo=1.16.0
+  - certifi=2021.5.30
+  - cffi=1.14.6
+  - cfitsio=3.470
+  - cftime=1.5.1
+  - cryptography=3.4.7
+  - curl=7.76.1
+  - cycler=0.10.0
+  - expat=2.4.1
+  - fontconfig=2.13.1
+  - freetype=2.10.4
+  - freexl=1.0.6
+  - gdal=3.2.1
+  - geos=3.8.1
+  - geotiff=1.6.0
+  - gettext=0.19.8.1
+  - gflags=2.2.2
+  - giflib=5.2.1
+  - glog=0.5.0
+  - grpc-cpp=1.37.1
+  - hdf4=4.2.15
+  - hdf5=1.10.6
+  - icu=68.1
+  - idna=3.1
+  - jinja2=3.0.1
+  - jmespath=0.10.0
+  - jpeg=9d
+  - json-c=0.13.1
+  - kealib=1.4.14
+  - kiwisolver=1.3.2
+  - krb5=1.17.2
+  - lcms2=2.12
+  - libblas=3.9.0
+  - libbrotlicommon=1.0.9
+  - libbrotlidec=1.0.9
+  - libbrotlienc=1.0.9
+  - libcblas=3.9.0
+  - libcurl=7.76.1
+  - libcxx=12.0.1
+  - libdap4=3.20.6
+  - libedit=3.1.20191231
+  - libev=4.33
+  - libevent=2.1.10
+  - libffi=3.4.2
+  - libgfortran5=9.3.0
+  - libglib=2.68.4
+  - libiconv=1.16
+  - libkml=1.3.0
+  - liblapack=3.9.0
+  - libnetcdf=4.7.4
+  - libnghttp2=1.43.0
+  - libopenblas=0.3.17
+  - libpng=1.6.37
+  - libpq=12.3
+  - libprotobuf=3.16.0
+  - librttopo=1.1.0
+  - libspatialite=5.0.1
+  - libssh2=1.10.0
+  - libthrift=0.14.1
+  - libtiff=4.2.0
+  - libutf8proc=2.6.1
+  - libwebp-base=1.2.1
+  - libxml2=2.9.12
+  - llvm-openmp=12.0.1
+  - lz4-c=1.9.3
+  - markupsafe=2.0.1
+  - matplotlib-base=3.4.3
+  - mock=4.0.3
+  - mpld3=0.5.1
+  - ncurses=6.2
+  - netcdf4=1.5.5.1
+  - numpy=1.21.2
+  - olefile=0.46
+  - openjpeg=2.4.0
+  - openssl=1.1.1l
+  - orc=1.6.7
+  - pandas=1.3.3
+  - parquet-cpp=1.5.1
+  - pcre=8.45
+  - pillow=8.1.0
+  - pip=21.2.4
+  - pixman=0.40.0
+  - poppler=0.89.0
+  - poppler-data=0.4.11
+  - postgresql=12.3
+  - proj=7.1.1
+  - py4j=0.10.9
+  - pyarrow=4.0.0
+  - pycparser=2.20
+  - pyopenssl=20.0.1
+  - pyparsing=2.4.7
+  - pyproj=2.6.1.post1
+  - pyshp=2.1.3
+  - pysocks=1.7.1
+  - pyspark=3.1.2
+  - python=3.9.7
+  - python-dateutil=2.8.2
+  - python_abi=3.9
+  - pytz=2021.1
+  - re2=2021.04.01
+  - readline=8.1
+  - s3transfer=0.3.7
+  - scipy=1.6.0
+  - setuptools=58.0.4
+  - shapely=1.7.1
+  - singledispatch=3.4.0.3
+  - six=1.16.0
+  - snappy=1.1.8
+  - sqlite=3.36.0
+  - tiledb=2.2.9
+  - tk=8.6.11
+  - tornado=6.1
+  - tzcode=2021a
+  - tzdata=2021a
+  - urllib3=1.26.7
+  - utm=0.6.0
+  - wheel=0.37.0
+  - xerces-c=3.2.3
+  - xz=5.2.5
+  - zlib=1.2.11
+  - zstd=1.4.9
+prefix: /opt/miniconda3/envs/sdap-nexus

Reply via email to