name: ocelot.social CI on: [push] jobs: ############################################################################## # JOB: PREPARE ##################################################### ############################################################################## prepare: name: Prepare runs-on: ubuntu-latest # needs: [nothing] steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - name: Checkout code uses: actions/checkout@v2 ########################################################################## # TODO: DO STUFF ??? ##################################################### ########################################################################## - name: Check translation files run: | scripts/translations/sort.sh scripts/translations/missing-keys.sh ############################################################################## # JOB: DOCKER BUILD TEST NEO4J ############################################### ############################################################################## build_test_neo4j: name: Docker Build Test - Neo4J runs-on: ubuntu-latest needs: [prepare] steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - name: Checkout code uses: actions/checkout@v2 ########################################################################## # NEO4J ################################################################## ########################################################################## - name: Neo4J | Build `community` image uses: docker/build-push-action@v2 with: repository: ocelotsocialnetwork/neo4j tags: latest path: neo4j/ push: false outputs: type=local,dest=/tmp/neo4j.tar cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: docker-neo4j-image path: /tmp/neo4j.tar ############################################################################## # JOB: DOCKER BUILD TEST BACKEND ############################################# ############################################################################## build_test_backend: name: Docker Build Test - Backend runs-on: ubuntu-latest needs: [prepare] steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - name: Checkout code uses: actions/checkout@v2 ########################################################################## # BUILD BACKEND DOCKER IMAGE (build) ##################################### ########################################################################## - name: backend | Build `build` image uses: docker/build-push-action@v2 with: repository: ocelotsocialnetwork/backend tags: build target: build path: backend/ push: false outputs: type=local,dest=/tmp/backend.tar cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: docker-backend-image path: /tmp/backend.tar ############################################################################## # JOB: DOCKER BUILD TEST WEBAPP ############################################## ############################################################################## build_test_webapp: name: Docker Build Test - WebApp runs-on: ubuntu-latest needs: [prepare] steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - name: Checkout code uses: actions/checkout@v2 ########################################################################## # BUILD WEBAPP DOCKER IMAGE (build) ###################################### ########################################################################## - name: webapp | Build `build` image uses: docker/build-push-action@v2 with: repository: ocelotsocialnetwork/webapp tags: build target: build path: webapp/ push: false load: true outputs: type=local,dest=/tmp/webapp.tar cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: docker-webapp-image path: /tmp/webapp.tar ############################################################################## # JOB: AFTER DOCKER BUILD #################################################### ############################################################################## after_docker_build: name: After Build runs-on: ubuntu-latest needs: [build_test_neo4j, build_test_backend, build_test_webapp] steps: - name: Do nothing run: echo "I do nothing" ############################################################################## # JOB: LINT BACKEND ########################################################## ############################################################################## lint_backend: name: Lint backend runs-on: ubuntu-latest needs: after_docker_build steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - name: Checkout code uses: actions/checkout@v2 ########################################################################## # DOWNLOAD DOCKER IMAGE ################################################## ########################################################################## - name: Download Docker Image (Artifact) uses: actions/download-artifact@v2 with: name: docker-backend-image path: /tmp/backend.tar - name: Load Docker Image run: docker load < /tmp/backend.tar ########################################################################## # LINT BACKEND ########################################################### ########################################################################## - name: backend | Lint run: docker run --rm ocelotsocialnetwork/backend:build yarn run lint ############################################################################## # JOB: LINT WEBAPP ########################################################### ############################################################################## lint_webapp: name: Lint backend runs-on: ubuntu-latest needs: after_docker_build steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - name: Checkout code uses: actions/checkout@v2 ########################################################################## # DOWNLOAD DOCKER IMAGE ################################################## ########################################################################## - name: Download Docker Image (Artifact) uses: actions/download-artifact@v2 with: name: docker-webapp-image path: /tmp/webapp.tar - name: Load Docker Image run: docker load < /tmp/webapp.tar ########################################################################## # LINT WEBAPP ############################################################ ########################################################################## - name: webapp | Lint run: docker run --rm ocelotsocialnetwork/webapp:build yarn run lint ############################################################################## # JOB: UNIT TESTS ############################################################ ############################################################################## #unit_tests: # name: Unit Tests # runs-on: ubuntu-latest # needs: prepare # steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## #- name: Checkout code # uses: actions/checkout@v2 ########################################################################## # UNIT TESTS BACKEND ##################################################### ########################################################################## #- name: backend | copy env files (webapp, backend) # run: cp webapp/.env.template webapp/.env # run: cp backend/.env.template backend/.env #- name: backend | docker-compose # run: docker-compose up #- name: backend | Unit tests # run: docker-compose exec backend yarn test #run: docker run --network container:webapp-frontend appropriate/curl -s --retry 10 --retry-connrefused http://localhost:5000/ ########################################################################## # UNIT TESTS WEBAPP ##################################################### ########################################################################## #- name: webapp | Unit tests # run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test ############################################################################## # JOB: DOCKER BUILD PRODUCTION & PUSH ######################################## ############################################################################## #build_production: # name: Docker Build Production & Push # runs-on: ubuntu-latest # needs: prepare # steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## #- name: Checkout code # uses: actions/checkout@v2 ########################################################################## # BACKEND ################################################################ ########################################################################## # TODO: We want to push this to dockerhub #- name: Build backend production image # uses: docker/build-push-action@v2 # with: # repository: ocelotsocialnetwork/backend # tags: production # target: production # path: backend/ # push: false ########################################################################## # WEBAPP ################################################################# ########################################################################## # TODO: We want to push this to dockerhub #- name: Build webapp production image # uses: docker/build-push-action@v2 # with: # repository: ocelotsocialnetwork/webapp # tags: production # target: production # path: webapp/ # push: false