Skip to content

Commit

Permalink
New GitHub Actions build process (#285)
Browse files Browse the repository at this point in the history
* First test of GitHub actions integration

* Changed actions checkout to specific version

* New build script to install dependencies on local environment in a single run

* Fixed issues with CI workflow for spring, springboot2 and struts

* More minor fixes to build workflow. getting there

* Renamed struts sample folder to match the naming used in the framework implementation

* Minor fix for Spring 4.3 build

* Added GitHub actions badge to readme
  • Loading branch information
sapessi committed Sep 30, 2019
1 parent 63faf2d commit 3ee467a
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 1 deletion.
70 changes: 70 additions & 0 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Serverless Java Container Continuous Integration
on:
push:
pull_request:
branches:
- master

jobs:
build_core:
name: Build and test core
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build latest
run: mvn -q clean install
working-directory: ./aws-serverless-java-container-core

build_jersey:
name: Build and test Jersey
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build latest
run: ./gha_build.sh jersey true true
- name: Build Jersey 2.26
run: ./gha_build.sh jersey false false -Djersey.version=2.26
- name: Build Jersey 2.27
run: ./gha_build.sh jersey false false -Djersey.version=2.27
- name: Build Jersey 2.28
run: ./gha_build.sh jersey false false -Djersey.version=2.28

build_spark:
name: Build and test Spark
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build latest
run: ./gha_build.sh spark true true
- name: Build Spark 2.8.0
run: ./gha_build.sh spark false false -Dspark.version=2.8.0

build_spring:
name: Build and test Spring & SpringBoot
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build latest
run: ./gha_build.sh spring true true
- name: Build Spring 4.3
run: ./gha_build.sh spring false false -Dspring.version=4.3.25.RELEASE -Dspring-security.version=4.2.13.RELEASE
- name: Build Spring 5.0
run: ./gha_build.sh spring false false -Dspring.version=5.0.15.RELEASE -Dspring-security.version=5.0.13.RELEASE

build_springboot2:
name: Build and test SpringBoot 2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build latest
run: ./gha_build.sh springboot2 true true
- name: Build Spring Boot 2.0
run: ./gha_build.sh springboot2 false false -Dspringboot.version=2.0.9.RELEASE -Dspring.version=5.0.13.RELEASE -Dspringsecurity.version=5.0.12.RELEASE

build_struts2:
name: Build and test Struts 2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build latest
run: ./gha_build.sh struts2 true true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Serverless Java container [![Build Status](https://travis-ci.org/awslabs/aws-serverless-java-container.svg?branch=master)](https://travis-ci.org/awslabs/aws-serverless-java-container) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.amazonaws.serverless/aws-serverless-java-container/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.amazonaws.serverless/aws-serverless-java-container) [![Help](http://img.shields.io/badge/help-gitter-E91E63.svg?style=flat-square)](https://gitter.im/awslabs/aws-serverless-java-container)
# Serverless Java container [![Build Status](https://github.com/awslabs/aws-serverless-java-container/workflows/.github/workflows/continuous-integration-workflow.yml/badge.svg)](https://github.com/awslabs/aws-serverless-java-container/actions) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.amazonaws.serverless/aws-serverless-java-container/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.amazonaws.serverless/aws-serverless-java-container) [![Help](http://img.shields.io/badge/help-gitter-E91E63.svg?style=flat-square)](https://gitter.im/awslabs/aws-serverless-java-container)
The `aws-serverless-java-container` makes it easy to run Java applications written with frameworks such as [Spring](https://spring.io/), [Spring Boot](https://projects.spring.io/spring-boot/), [Apache Struts](http://struts.apache.org/), [Jersey](https://jersey.java.net/), or [Spark](http://sparkjava.com/) in [AWS Lambda](https://aws.amazon.com/lambda/).

Serverless Java Container natively supports API Gateway's proxy integration models for requests and responses, you can create and inject custom models for methods that use custom mappings.
Expand Down
123 changes: 123 additions & 0 deletions gha_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env bash

WORKING_DIR=$(pwd)
FRAMEWORK=$1
RUN_ARCHETYPE=$2
RUN_SAMPLES=$3
EXTRA_PARAMS=${*:4}

echo "Starting build script for ${FRAMEWORK} with params ${EXTRA_PARAMS}"

if [[ -z ${FRAMEWORK} ]] ; then
echo "Missing framework parameter"
exit 1
fi

function install {
# we skip tests for core because we assume they will be run in a separate branch of the workflow
cd ${WORKING_DIR}/aws-serverless-java-container-core && mvn -q clean install -DskipTests
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${WORKING_DIR}/aws-serverless-java-container-$1 && mvn -q clean install ${@:2}
if [[ "$?" -ne 0 ]]; then
exit 1
fi
}

function archetype {
ARCHETYPE_NAME=aws-serverless-$1-archetype
PROJ_NAME=$1-archetype-test
cd ${WORKING_DIR}/${ARCHETYPE_NAME} && mvn -q clean install
ARCHETYPE_TEST_DIR=${WORKING_DIR}/$1_archetype_test
mkdir -p ${ARCHETYPE_TEST_DIR}
cd ${ARCHETYPE_TEST_DIR} && mvn archetype:generate -DgroupId=my.service -DartifactId=${PROJ_NAME} -Dversion=1.0-SNAPSHOT \
-DarchetypeGroupId=com.amazonaws.serverless.archetypes \
-DarchetypeArtifactId=${ARCHETYPE_NAME} \
-DarchetypeCatalog=local \
-DinteractiveMode=false
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${ARCHETYPE_TEST_DIR}/${PROJ_NAME} && mvn -q clean package -Pshaded-jar
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${ARCHETYPE_TEST_DIR}/${PROJ_NAME} && mvn -q clean package
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${ARCHETYPE_TEST_DIR}/${PROJ_NAME} && gradle -q wrapper
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${ARCHETYPE_TEST_DIR}/${PROJ_NAME} && ./gradlew wrapper --gradle-version 5.0
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${ARCHETYPE_TEST_DIR}/${PROJ_NAME} && ./gradlew -q clean build
if [[ "$?" -ne 0 ]]; then
exit 1
fi
}

function sample {
# force to pet store for now. In the future we may loop over all samples
SAMPLE_FOLDER=${WORKING_DIR}/samples/$1/pet-store
cd ${SAMPLE_FOLDER} && mvn -q clean package
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${SAMPLE_FOLDER} && gradle -q wrapper
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${SAMPLE_FOLDER} && ./gradlew wrapper --gradle-version 5.0
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${SAMPLE_FOLDER} && ./gradlew -q clean build
if [[ "$?" -ne 0 ]]; then
exit 1
fi

SAM_FILE=${SAMPLE_FOLDER}/sam.yaml
if [[ -f "$SAM_FILE" ]]; then
TARGET_ZIP=$(cat ${SAM_FILE} | grep CodeUri | sed -e 's/^.*:\ //g')
if [[ ! -f "${SAMPLE_FOLDER}/${TARGET_ZIP}" ]]; then
echo "COULD NOT FIND TARGET ZIP FILE $TARGET_ZIP FOR $1 SAMPLE"
exit 1
fi
else
echo "COULD NOT FIND SAM FILE: '${SAM_FILE}'"
exit 1
fi
}

# set up the master pom otherwise we won't be able to find new dependencies
cd ${WORKING_DIR}/ && mvn -q --non-recursive clean install

case $1 in
# special case for spring since we include both spring and springboot 1.x in one package
spring)
install ${FRAMEWORK} ${EXTRA_PARAMS}
if [[ "$RUN_ARCHETYPE" = true ]] ; then
archetype ${FRAMEWORK}
archetype springboot
fi
if [[ "$RUN_SAMPLES" = true ]] ; then
sample ${FRAMEWORK}
sample springboot
fi
break
;;
*)
install ${FRAMEWORK} ${EXTRA_PARAMS}
if [[ "$RUN_ARCHETYPE" = true ]] ; then
archetype ${FRAMEWORK}
fi
if [[ "$RUN_SAMPLES" = true ]] ; then
sample ${FRAMEWORK}
fi
;;
esac
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3ee467a

Please sign in to comment.