Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Automated build test #4

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
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
119 changes: 119 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Continuous integration
name: CI

# Run in master and dev branches and in all pull requests to those branches
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
DOCKER_IMAGE: thehyve/ohdsi-atlas

jobs:
# Build and test the code
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Caches NPM dependencies, as long as the package-lock.json is not modified
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12

- name: Build code
run: npm run build

# Check that the docker image builds correctly
# Push to ohdsi/atlas:master for commits on master.
docker:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

# Add Docker labels and tags
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ${{ env.DOCKER_IMAGE }}

# Setup docker build environment
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Set build parameters
id: build_params
run: |
if [ ${{ github.event_name == 'pull_request' }} ]; then
echo "::set-output name=push::false"
echo "::set-output name=load::true"
echo "::set-output name=platforms::linux/amd64"
else
echo "::set-output name=push::true"
echo "::set-output name=load::false"
echo "::set-output name=platforms::linux/amd64,linux/arm/v7,linux/arm64"
fi

- name: Login to DockerHub
uses: docker/login-action@v1
if: steps.build_params.outputs.push == 'true'
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
platforms: ${{ steps.build_params.outputs.platforms }}
push: ${{ steps.build_params.outputs.push }}
load: ${{ steps.build_params.outputs.load }}
tags: ${{ steps.docker_meta.outputs.tags }}
# Use runtime labels from docker_meta as well as fixed labels
labels: |
${{ steps.docker_meta.outputs.labels }}
maintainer=Joris Borgdorff <[email protected]>, Lee Evans - www.ltscomputingllc.com
org.opencontainers.image.authors=Joris Borgdorff <[email protected]>, Lee Evans - www.ltscomputingllc.com
org.opencontainers.image.vendor=OHDSI

# If the image was pushed, we need to pull it again to inspect it
- name: Pull image
if: steps.build_params.outputs.push == 'true'
run: docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}

- name: Inspect image
run: |
docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
104 changes: 104 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Create release files
name: Release

on:
release:
types: [published]

env:
DOCKER_IMAGE: thehyve/ohdsi-atlas

jobs:
upload:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12

- name: NPM cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
run: npm install

# Compile the code
- name: Build code
run: npm run build:docker

- name: Make distribution
run: |
mkdir atlas
cp -r LICENSE README.md node_modules js images index.html atlas
zip -r atlas.zip atlas

# Upload it to GitHub
- name: Upload to GitHub
uses: AButler/[email protected]
with:
files: 'atlas.zip'
repo-token: ${{ secrets.GITHUB_TOKEN }}

# Build and push tagged release docker image to
# ohdsi/atlas:<version> and ohdsi/atlas:latest.
docker:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2

# Add Docker labels and tags
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ${{ env.DOCKER_IMAGE }}
tag-match: v(.*)
tag-match-group: 1

# Setup docker build environment
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
# Allow running the image on the architectures supported by nginx-unprivileged:alpine.
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
# Use runtime labels from docker_meta as well as fixed labels
labels: |
${{ steps.docker_meta.outputs.labels }}
maintainer=Joris Borgdorff <[email protected]>, Lee Evans - www.ltscomputingllc.com
org.opencontainers.image.authors=Joris Borgdorff <[email protected]>, Lee Evans - www.ltscomputingllc.com
org.opencontainers.image.vendor=OHDSI

- name: Inspect image
run: |
docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
19 changes: 4 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the source
FROM node:12 as builder
FROM node:12-alpine as builder

WORKDIR /code

Expand Down Expand Up @@ -28,24 +28,13 @@ RUN RUN find . -type f "(" \
# Production Nginx image
FROM nginxinc/nginx-unprivileged:1.19-alpine

# Published version of Atlas
ARG VERSION=SNAPSHOT
# Datetime that this image was created in ISO 8601 format
ARG CREATED=SNAPSHOT
# Git revision
ARG REVISION=SNAPSHOT

LABEL org.opencontainers.image.title="OHDSI ATLAS"
LABEL org.opencontainers.image.title="OHDSI-Atlas"
LABEL org.opencontainers.image.authors="Joris Borgdorff <[email protected]>, Lee Evans - www.ltscomputingllc.com"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.description="ATLAS is an open source software tool for researchers \
to conduct scientific analyses on standardized observational data converted to the \
OMOP Common Data Model. It is served as a static site by Nginx."
LABEL org.opencontainers.image.description="ATLAS is an open source software tool for researchers to \
conduct scientific analyses on standardized observational data"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.vendor="OHDSI"
LABEL org.opencontainers.image.source="https://github.com/OHDSI/Atlas"
LABEL org.opencontainers.image.created="${CREATED}"
LABEL org.opencontainers.image.revision="${REVISION}"

# URL where WebAPI can be queried by the client
ENV WEBAPI_URL=http://localhost:8080/WebAPI/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.5",
"esprima": "^4.0.1",
"html-document": "^0.8.1",
"genversion": "^2.2.0",
"html-document": "^0.8.1",
"requirejs": "^2.3.6",
"rimraf": "^2.6.2",
"terser": "3.17.0"
Expand Down