From 3035ec9bef912a2a54c7eecbd9d860b062fc9620 Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Fri, 3 Jul 2020 14:40:57 +0530 Subject: [PATCH] Adding the Github action workflow for the server code (#24) * Adding the Github action workflow for the server code * Modifying the redis endpoint in application-test.properties to point to localhost because the Docker service exposes ports to the host --- .github/workflows/server.yml | 81 +++++++++++++++++++ .../resources/application-test.properties | 4 +- 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/server.yml diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml new file mode 100644 index 0000000000..d732f51175 --- /dev/null +++ b/.github/workflows/server.yml @@ -0,0 +1,81 @@ +# This workflow is responsible for building, testing & packaging the Java server codebase +name: Appsmith Server Workflow + +on: + push: + branches: [ release, master ] + # Only trigger if files have changed in this specific path + paths: + - 'app/server/**' + pull_request: + branches: [ release, master ] + paths: + - 'app/server/**' +# Change the working directory for all the jobs in this workflow +defaults: + run: + working-directory: app/server + +jobs: + build: + runs-on: ubuntu-latest + + # Service containers to run with this job. Required for running tests + services: + # Label used to access the service container + redis: + # Docker Hub image for Redis + image: redis + ports: + # Opens tcp port 6379 on the host and service container + - 6379:6379 + + steps: + # Checkout the code + - uses: actions/checkout@v2 + + # Setup Java + - name: Set up JDK 1.11 + uses: actions/setup-java@v1 + with: + java-version: 1.11 + + # Retrieve maven dependencies from cache. After a successful run, these dependencies are cached again + - name: Cache maven dependencies + uses: actions/cache@v2 + env: + cache-name: cache-maven-dependencies + with: + # maven dependencies are stored in `~/.m2` on Linux/macOS + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + # Build and test the code + - name: Build and test + env: + SPRING_PROFILES_ACTIVE: test + run: mvn -B package -Dspring.profiles.active=$SPRING_PROFILES_ACTIVE + + # Here, the GITHUB_REF is of type /refs/head/. We extract branch_name from this by removing the + # first 11 characters. This can be used to build images for several branches + - name: Get the version to tag the Docker image + id: vars + run: echo ::set-output name=tag::$(echo ${GITHUB_REF:11}) + + # Build release Docker image and push to Docker Hub + - name: Push release image to Docker Hub + if: success() && github.ref == 'refs/heads/release' + run: | + docker build -t appsmith/test-appsmith-repo:${{steps.vars.outputs.tag}} . + echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin + docker push appsmith/test-appsmith-repo + + # Build master Docker image and push to Docker Hub + - name: Push master image to Docker Hub with commit tag + if: success() && github.ref == 'refs/heads/master' + run: | + docker build -t appsmith/test-appsmith-repo:${GITHUB_SHA} . + docker build -t appsmith/test-appsmith-repo:latest . + echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin + docker push appsmith/test-appsmith-repo \ No newline at end of file diff --git a/app/server/appsmith-server/src/test/resources/application-test.properties b/app/server/appsmith-server/src/test/resources/application-test.properties index 6c9209ad65..cd5b18a780 100644 --- a/app/server/appsmith-server/src/test/resources/application-test.properties +++ b/app/server/appsmith-server/src/test/resources/application-test.properties @@ -26,7 +26,7 @@ com.rollbar.access-token=random-value com.rollbar.environment=development # Redis Properties -spring.redis.host=redis +spring.redis.host=localhost spring.redis.port=6379 # ACL config parameters @@ -41,4 +41,4 @@ spring.mail.port=587 spring.mail.username=AKIAVWHAAGIQOHPT4BZ7 spring.mail.password=BEE5W6i7YznAJ/YDOLbppovmOlRzxXElJ+uJtGhdCfjY spring.mail.properties.mail.smtp.auth=true -spring.mail.properties.mail.smtp.starttls.enable=true \ No newline at end of file +spring.mail.properties.mail.smtp.starttls.enable=true