Update CI
This commit is contained in:
parent
887808508c
commit
2527e3198e
109
.github/workflows/ci.yaml
vendored
109
.github/workflows/ci.yaml
vendored
@ -1,35 +1,26 @@
|
|||||||
name: Continuous Integration
|
name: Continuous Integration
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: ['*', series/*]
|
branches: ["*", series/*]
|
||||||
push:
|
push:
|
||||||
branches: ['*', series/*]
|
branches: ["*", series/*]
|
||||||
tags: [v*]
|
tags: [v*]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Label of the container job
|
# Label of the container job
|
||||||
build:
|
build:
|
||||||
name: Build and Test
|
name: Build and Test
|
||||||
# Containers must run in Linux based operating systems
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Docker Hub image that `container-job` executes in
|
# container: node:12-buster
|
||||||
# container: node:12-buster
|
|
||||||
env:
|
env:
|
||||||
# The hostname used to communicate with the PostgreSQL service container
|
|
||||||
CODEGEN_DB_HOST: localhost
|
CODEGEN_DB_HOST: localhost
|
||||||
# The default PostgreSQL port
|
|
||||||
CODEGEN_DB_PORT: 5432
|
CODEGEN_DB_PORT: 5432
|
||||||
CODEGEN_DB_USER: codegenuser
|
CODEGEN_DB_USER: codegenuser
|
||||||
CODEGEN_DB_PASSWORD: postgres
|
CODEGEN_DB_PASSWORD: postgres
|
||||||
CODEGEN_DB_NAME: codegendb
|
CODEGEN_DB_NAME: codegendb
|
||||||
|
|
||||||
# Service containers to run with `container-job`
|
|
||||||
services:
|
services:
|
||||||
# Label used to access the service container
|
|
||||||
postgres:
|
postgres:
|
||||||
# Docker Hub image
|
|
||||||
image: postgres:12-alpine
|
image: postgres:12-alpine
|
||||||
# Provide the password for postgres
|
|
||||||
env:
|
env:
|
||||||
POSTGRES_PASSWORD: postgres
|
POSTGRES_PASSWORD: postgres
|
||||||
POSTGRES_USER: codegenuser
|
POSTGRES_USER: codegenuser
|
||||||
@ -44,78 +35,40 @@ jobs:
|
|||||||
- 5432:5432
|
- 5432:5432
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Downloads a copy of the code in your repository before running CI tests
|
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Coursier cache
|
- name: Coursier cache
|
||||||
uses: coursier/cache-action@v6
|
uses: coursier/cache-action@v6
|
||||||
# with:
|
|
||||||
# path: |
|
|
||||||
# ~/.cache/blah
|
|
||||||
# - name: Cache SBT
|
|
||||||
# uses: actions/cache@v2
|
|
||||||
# id: cache-sbt-dependencies
|
|
||||||
# with:
|
|
||||||
# path: |
|
|
||||||
# $HOME/.sbt
|
|
||||||
# $HOME/.ivy2/cache
|
|
||||||
# $HOME/.coursier/cache/v1
|
|
||||||
# $HOME/.cache/coursier/v1
|
|
||||||
# key: ${{ runner.os }}-sbtnew-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
|
|
||||||
# restore-keys: |
|
|
||||||
# ${{ runner.os }}-sbtnew-
|
|
||||||
- name: Setup
|
- name: Setup
|
||||||
uses: olafurpg/setup-scala@v10
|
uses: olafurpg/setup-scala@v10
|
||||||
with:
|
with:
|
||||||
java-version: adopt@1.11
|
java-version: adopt@1.11
|
||||||
# - name: Install docker
|
- name: Migrate
|
||||||
# run: |
|
run: csbt flyway/flywayMigrate
|
||||||
# curl -fsSL https://get.docker.com -o get-docker.sh
|
|
||||||
# sh get-docker.sh
|
|
||||||
# docker login -p "${{ secrets.DOCKER_LOGIN_PASSWORD }}" -u rohansircar
|
|
||||||
# - name: Migrate
|
|
||||||
# run: csbt flyway/flywayMigrate
|
|
||||||
- name: Compile
|
- name: Compile
|
||||||
run: |
|
run: |
|
||||||
csbt flyway/flywayMigrate
|
csbt "compile; test:compile"
|
||||||
csbt compile
|
|
||||||
csbt test:compile
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: |
|
run: |
|
||||||
echo $GITHUB_REF
|
echo $GITHUB_REF
|
||||||
echo ${GITHUB_REF#refs/*/}
|
echo ${GITHUB_REF#refs/*/}
|
||||||
# echo ${github.event_name}
|
# csbt test
|
||||||
# csbt test
|
|
||||||
# ls -alh ~/
|
|
||||||
# - name: Package
|
|
||||||
# run: csbt docker:publish
|
|
||||||
|
|
||||||
|
|
||||||
# Label of the container job
|
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
name: Publish Release Docker Image
|
name: Publish Release Docker Image
|
||||||
needs: [build]
|
needs: [build]
|
||||||
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v')
|
||||||
# Containers must run in Linux based operating systems
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Docker Hub image that `container-job` executes in
|
# container: node:12-buster
|
||||||
# container: node:12-buster
|
|
||||||
env:
|
env:
|
||||||
# The hostname used to communicate with the PostgreSQL service container
|
|
||||||
CODEGEN_DB_HOST: localhost
|
CODEGEN_DB_HOST: localhost
|
||||||
# The default PostgreSQL port
|
|
||||||
CODEGEN_DB_PORT: 5432
|
CODEGEN_DB_PORT: 5432
|
||||||
CODEGEN_DB_USER: codegenuser
|
CODEGEN_DB_USER: codegenuser
|
||||||
CODEGEN_DB_PASSWORD: postgres
|
CODEGEN_DB_PASSWORD: postgres
|
||||||
CODEGEN_DB_NAME: codegendb
|
CODEGEN_DB_NAME: codegendb
|
||||||
# Service containers to run with `container-job`
|
DOCKER_JAVA_IMAGE: azul/zulu-openjdk-alpine:11-jre-headless
|
||||||
services:
|
services:
|
||||||
# Label used to access the service container
|
|
||||||
postgres:
|
postgres:
|
||||||
# Docker Hub image
|
|
||||||
image: postgres:12-alpine
|
image: postgres:12-alpine
|
||||||
# Provide the password for postgres
|
|
||||||
env:
|
env:
|
||||||
POSTGRES_PASSWORD: postgres
|
POSTGRES_PASSWORD: postgres
|
||||||
POSTGRES_USER: codegenuser
|
POSTGRES_USER: codegenuser
|
||||||
@ -129,7 +82,6 @@ jobs:
|
|||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
steps:
|
steps:
|
||||||
# Downloads a copy of the code in your repository before running CI tests
|
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Coursier cache
|
- name: Coursier cache
|
||||||
@ -138,39 +90,35 @@ jobs:
|
|||||||
uses: olafurpg/setup-scala@v10
|
uses: olafurpg/setup-scala@v10
|
||||||
with:
|
with:
|
||||||
java-version: adopt@1.11
|
java-version: adopt@1.11
|
||||||
- name: Docker login
|
- name: Login to Docker Hub
|
||||||
run: |
|
uses: docker/login-action@v1
|
||||||
docker login -p "${{ secrets.DOCKER_LOGIN_PASSWORD }}" -u rohansircar
|
with:
|
||||||
|
username: rohansircar
|
||||||
|
password: ${{ secrets.DOCKER_LOGIN_PASSWORD }}
|
||||||
|
- name: Migrate
|
||||||
|
run: csbt flyway/flywayMigrate
|
||||||
- name: Publish
|
- name: Publish
|
||||||
run: |
|
run: |
|
||||||
csbt flyway/flywayMigrate
|
|
||||||
csbt compile
|
|
||||||
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||||
csbt docker:stage
|
csbt docker:stage
|
||||||
|
|
||||||
publish-devel:
|
publish-devel:
|
||||||
name: Publish Devel Docker Image
|
name: Publish Devel Docker Image
|
||||||
needs: [build]
|
needs: [build]
|
||||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/devel'
|
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/devel'
|
||||||
# Containers must run in Linux based operating systems
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Docker Hub image that `container-job` executes in
|
# container: node:12-buster
|
||||||
# container: node:12-buster
|
|
||||||
env:
|
env:
|
||||||
# The hostname used to communicate with the PostgreSQL service container
|
|
||||||
CODEGEN_DB_HOST: localhost
|
CODEGEN_DB_HOST: localhost
|
||||||
# The default PostgreSQL port
|
|
||||||
CODEGEN_DB_PORT: 5432
|
CODEGEN_DB_PORT: 5432
|
||||||
CODEGEN_DB_USER: codegenuser
|
CODEGEN_DB_USER: codegenuser
|
||||||
CODEGEN_DB_PASSWORD: postgres
|
CODEGEN_DB_PASSWORD: postgres
|
||||||
CODEGEN_DB_NAME: codegendb
|
CODEGEN_DB_NAME: codegendb
|
||||||
# Service containers to run with `container-job`
|
DOCKER_JAVA_IMAGE: azul/zulu-openjdk-alpine:11-jre-headless
|
||||||
|
DOCKER_PUBLISH_TAG: latest
|
||||||
services:
|
services:
|
||||||
# Label used to access the service container
|
|
||||||
postgres:
|
postgres:
|
||||||
# Docker Hub image
|
|
||||||
image: postgres:12-alpine
|
image: postgres:12-alpine
|
||||||
# Provide the password for postgres
|
|
||||||
env:
|
env:
|
||||||
POSTGRES_PASSWORD: postgres
|
POSTGRES_PASSWORD: postgres
|
||||||
POSTGRES_USER: codegenuser
|
POSTGRES_USER: codegenuser
|
||||||
@ -184,7 +132,6 @@ jobs:
|
|||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
steps:
|
steps:
|
||||||
# Downloads a copy of the code in your repository before running CI tests
|
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Coursier cache
|
- name: Coursier cache
|
||||||
@ -193,11 +140,13 @@ jobs:
|
|||||||
uses: olafurpg/setup-scala@v10
|
uses: olafurpg/setup-scala@v10
|
||||||
with:
|
with:
|
||||||
java-version: adopt@1.11
|
java-version: adopt@1.11
|
||||||
- name: Docker login
|
- name: Login to Docker Hub
|
||||||
run: |
|
uses: docker/login-action@v1
|
||||||
docker login -p "${{ secrets.DOCKER_LOGIN_PASSWORD }}" -u rohansircar
|
with:
|
||||||
|
username: rohansircar
|
||||||
|
password: ${{ secrets.DOCKER_LOGIN_PASSWORD }}
|
||||||
|
- name: Migrate
|
||||||
|
run: csbt flyway/flywayMigrate
|
||||||
- name: Publish
|
- name: Publish
|
||||||
run: |
|
run: |
|
||||||
csbt flyway/flywayMigrate
|
|
||||||
csbt compile
|
|
||||||
csbt docker:stage
|
csbt docker:stage
|
||||||
|
18
build.sbt
18
build.sbt
@ -27,6 +27,14 @@ lazy val databaseUrl =
|
|||||||
lazy val databaseUser = sys.env.getOrElse("CODEGEN_DB_USER", "test_user")
|
lazy val databaseUser = sys.env.getOrElse("CODEGEN_DB_USER", "test_user")
|
||||||
lazy val databasePassword = sys.env.getOrElse("CODEGEN_DB_PASSWORD", "password")
|
lazy val databasePassword = sys.env.getOrElse("CODEGEN_DB_PASSWORD", "password")
|
||||||
|
|
||||||
|
lazy val dockerJavaImage =
|
||||||
|
sys.env.getOrElse("DOCKER_JAVA_IMAGE", "openjdk:11-jre-slim-buster")
|
||||||
|
lazy val releaseVersion = sys.env.getOrElse("RELEASE_VERSION", "0.0.1-SNAPSHOT")
|
||||||
|
lazy val dockerPublishTag = sys.env
|
||||||
|
.get("DOCKER_PUBLISH_TAG")
|
||||||
|
.orElse(sys.env.get("RELEASE_VERSION"))
|
||||||
|
.getOrElse("latest")
|
||||||
|
|
||||||
lazy val flyway = (project in file("modules/flyway"))
|
lazy val flyway = (project in file("modules/flyway"))
|
||||||
.enablePlugins(FlywayPlugin)
|
.enablePlugins(FlywayPlugin)
|
||||||
.settings(
|
.settings(
|
||||||
@ -39,13 +47,15 @@ lazy val flyway = (project in file("modules/flyway"))
|
|||||||
)
|
)
|
||||||
|
|
||||||
lazy val root = (project in file("."))
|
lazy val root = (project in file("."))
|
||||||
.enablePlugins(CodegenPlugin, DockerPlugin, JavaAppPackaging)
|
.enablePlugins(CodegenPlugin, DockerPlugin, JavaAppPackaging, AshScriptPlugin)
|
||||||
.settings(
|
.settings(
|
||||||
organization := "wow.doge",
|
organization := "wow.doge",
|
||||||
name := "http4s-demo",
|
name := "http4s-demo",
|
||||||
version := "0.0.1-SNAPSHOT",
|
version := releaseVersion,
|
||||||
version in Docker := "0.0.1",
|
version in Docker := dockerPublishTag,
|
||||||
dockerBaseImage := "openjdk:11-slim",
|
// alpine java docker image for smaller size - "azul/zulu-openjdk-alpine:11-jre-headless"
|
||||||
|
dockerBaseImage := dockerJavaImage,
|
||||||
|
dockerExposedPorts := Seq(8081),
|
||||||
dockerUsername := Some("rohansircar"),
|
dockerUsername := Some("rohansircar"),
|
||||||
scalacOptions ++= Seq(
|
scalacOptions ++= Seq(
|
||||||
"-encoding",
|
"-encoding",
|
||||||
|
Loading…
Reference in New Issue
Block a user