From 3dc945cc70b39df63f47cc02d9b620f7f50a0dbf Mon Sep 17 00:00:00 2001 From: Rohan Sircar <47449547+rohan-sircar@users.noreply.github.com> Date: Sat, 17 Apr 2021 19:03:30 +0530 Subject: [PATCH] Update build.yaml (#1) --- .github/workflows/build.yaml | 55 ---------- .github/workflows/ci.yaml | 207 +++++++++++++++++++++++++++++++++++ 2 files changed, 207 insertions(+), 55 deletions(-) delete mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 9c40abd..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,55 +0,0 @@ -name: PostgreSQL service example -on: push - -jobs: - # Label of the container job - build: - # Containers must run in Linux based operating systems - runs-on: ubuntu-latest - # Docker Hub image that `container-job` executes in - container: node:12-buster - env: - # The hostname used to communicate with the PostgreSQL service container - CODEGEN_DB_HOST: postgres - # The default PostgreSQL port - CODEGEN_DB_PORT: 5432 - CODEGEN_DB_USER: codegenuser - CODEGEN_DB_PASSWOD: postgres - CODEGEN_DB_NAME: codegendb - - # Service containers to run with `container-job` - services: - # Label used to access the service container - postgres: - # Docker Hub image - image: postgres - # Provide the password for postgres - env: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: codegenuser - POSTGRES_DB: codegendb - # Set health checks to wait until postgres has started - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 -# ports: -# - 5435:5432 - - steps: - # Downloads a copy of the code in your repository before running CI tests - - name: Check out repository code - uses: actions/checkout@v2 - - name: Coursier cache - uses: coursier/cache-action@v6 - - name: Setup - uses: olafurpg/setup-scala@v10 - with: - java-version: adopt@1.11 - - name: Migrate - run: csbt flyway/flywayMigrate - - name: Run Tests - run: csbt test - - name: Package - run: csbt docker:stage diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..90aed08 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,207 @@ +name: Continuous Integration +on: + pull_request: + branches: ['*', series/*] + push: + branches: ['*', series/*] + tags: [v*] + +jobs: + # Label of the container job + build: + name: Build and Test + # Containers must run in Linux based operating systems + runs-on: ubuntu-latest + # Docker Hub image that `container-job` executes in +# container: node:12-buster + env: + # The hostname used to communicate with the PostgreSQL service container + CODEGEN_DB_HOST: localhost + # The default PostgreSQL port + CODEGEN_DB_PORT: 5432 + CODEGEN_DB_USER: codegenuser + CODEGEN_DB_PASSWORD: postgres + CODEGEN_DB_NAME: codegendb + + # Service containers to run with `container-job` + services: + # Label used to access the service container + postgres: + # Docker Hub image + image: postgres:12-alpine + # Provide the password for postgres + env: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: codegenuser + POSTGRES_DB: codegendb + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + # Downloads a copy of the code in your repository before running CI tests + - name: Check out repository code + uses: actions/checkout@v2 + - name: Coursier cache + 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 + uses: olafurpg/setup-scala@v10 + with: + java-version: adopt@1.11 +# - name: Install docker +# run: | +# 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 + run: | + csbt flyway/flywayMigrate + csbt compile + csbt test:compile + - name: Run Tests + run: | + echo $GITHUB_REF + echo ${GITHUB_REF#refs/*/} +# echo ${github.event_name} +# csbt test +# ls -alh ~/ +# - name: Package +# run: csbt docker:publish + + + # Label of the container job + + publish: + name: Publish Release Docker Image + needs: [build] + if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) + # Containers must run in Linux based operating systems + runs-on: ubuntu-latest + # Docker Hub image that `container-job` executes in +# container: node:12-buster + env: + # The hostname used to communicate with the PostgreSQL service container + CODEGEN_DB_HOST: localhost + # The default PostgreSQL port + CODEGEN_DB_PORT: 5432 + CODEGEN_DB_USER: codegenuser + CODEGEN_DB_PASSWORD: postgres + CODEGEN_DB_NAME: codegendb + # Service containers to run with `container-job` + services: + # Label used to access the service container + postgres: + # Docker Hub image + image: postgres:12-alpine + # Provide the password for postgres + env: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: codegenuser + POSTGRES_DB: codegendb + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: + # Downloads a copy of the code in your repository before running CI tests + - name: Check out repository code + uses: actions/checkout@v2 + - name: Coursier cache + uses: coursier/cache-action@v6 + - name: Setup + uses: olafurpg/setup-scala@v10 + with: + java-version: adopt@1.11 + - name: Install docker + run: | + curl -fsSL https://get.docker.com -o get-docker.sh + sh get-docker.sh + docker login -p "${{ secrets.DOCKER_LOGIN_PASSWORD }}" -u rohansircar + - name: Publish + run: | + csbt flyway/flywayMigrate + csbt compile + echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + csbt docker:stage + + publish-devel: + name: Publish Devel Docker Image + needs: [build] + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/devel' + # Containers must run in Linux based operating systems + runs-on: ubuntu-latest + # Docker Hub image that `container-job` executes in +# container: node:12-buster + env: + # The hostname used to communicate with the PostgreSQL service container + CODEGEN_DB_HOST: localhost + # The default PostgreSQL port + CODEGEN_DB_PORT: 5432 + CODEGEN_DB_USER: codegenuser + CODEGEN_DB_PASSWORD: postgres + CODEGEN_DB_NAME: codegendb + # Service containers to run with `container-job` + services: + # Label used to access the service container + postgres: + # Docker Hub image + image: postgres:12-alpine + # Provide the password for postgres + env: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: codegenuser + POSTGRES_DB: codegendb + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: + # Downloads a copy of the code in your repository before running CI tests + - name: Check out repository code + uses: actions/checkout@v2 + - name: Coursier cache + uses: coursier/cache-action@v6 + - name: Setup + uses: olafurpg/setup-scala@v10 + with: + java-version: adopt@1.11 + - name: Install docker + run: | + curl -fsSL https://get.docker.com -o get-docker.sh + sh get-docker.sh + docker login -p "${{ secrets.DOCKER_LOGIN_PASSWORD }}" -u rohansircar + - name: Publish + run: | + csbt flyway/flywayMigrate + csbt compile + csbt docker:stage