|
| 1 | +# This is a basic workflow to help you get started with Actions |
| 2 | + |
| 3 | +name: CI |
| 4 | + |
| 5 | +# Controls when the workflow will run |
| 6 | +on: |
| 7 | + # Triggers the workflow on push or pull request events but only for the master branch |
| 8 | + push: |
| 9 | + branches: [ master ] |
| 10 | + pull_request: |
| 11 | + branches: [ master ] |
| 12 | + |
| 13 | + # Allows you to run this workflow manually from the Actions tab |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 17 | +jobs: |
| 18 | + # This workflow contains a single job called "build" |
| 19 | + unitAndFunctionalTests: |
| 20 | + if: github.repository == 'eiffel-community/eiffel-intelligence-frontend' |
| 21 | + # The type of runner that the job will run on |
| 22 | + runs-on: ubuntu-18.04 |
| 23 | + env: |
| 24 | + EI_BACKEND_PORT: 8099 |
| 25 | + JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64 |
| 26 | + M2_HOME: /opt/apache-maven-3.6.3 |
| 27 | + MAVEN_HOME: /opt/apache-maven-3.6.3 |
| 28 | + |
| 29 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 30 | + steps: |
| 31 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 32 | + - uses: actions/checkout@v3 |
| 33 | + |
| 34 | + # Runs a set of commands using the runners shell |
| 35 | + # Run before every job |
| 36 | + - name: Install Java |
| 37 | + run: | |
| 38 | + sudo apt-get update |
| 39 | + sudo apt-get install -y openjdk-8-jdk |
| 40 | + java -version |
| 41 | + uname -a |
| 42 | + chmod +x pom.xml |
| 43 | + |
| 44 | + - name: Install Maven |
| 45 | + shell: bash |
| 46 | + run: | |
| 47 | + wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp |
| 48 | + tar xf /tmp/apache-maven-3.6.3-bin.tar.gz -C /opt |
| 49 | + echo "${M2_HOME}/bin" >> $GITHUB_PATH |
| 50 | + |
| 51 | + - name: Run unit and functional tests |
| 52 | + run: | |
| 53 | + mvn test -B |
| 54 | + |
| 55 | + |
| 56 | + integrationTests: |
| 57 | + if: github.repository == 'eiffel-community/eiffel-intelligence-frontend' |
| 58 | + # The type of runner that the job will run on |
| 59 | + runs-on: ubuntu-18.04 |
| 60 | + env: |
| 61 | + EI_BACKEND_PORT: 8099 |
| 62 | + JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64 |
| 63 | + M2_HOME: /opt/apache-maven-3.6.3 |
| 64 | + MAVEN_HOME: /opt/apache-maven-3.6.3 |
| 65 | + |
| 66 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 67 | + steps: |
| 68 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 69 | + - uses: actions/checkout@v3 |
| 70 | + |
| 71 | + # Runs a set of commands using the runners shell |
| 72 | + # Run before every job |
| 73 | + - name: Install Java |
| 74 | + run: | |
| 75 | + sudo apt-get update |
| 76 | + sudo apt-get install -y openjdk-8-jdk |
| 77 | + java -version |
| 78 | + uname -a |
| 79 | + chmod +x pom.xml |
| 80 | + mvn --version |
| 81 | + |
| 82 | + - name: Install Maven |
| 83 | + shell: bash |
| 84 | + run: | |
| 85 | + wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp |
| 86 | + tar xf /tmp/apache-maven-3.6.3-bin.tar.gz -C /opt |
| 87 | + ln -s /opt/apache-maven-3.6.3 /opt/maven |
| 88 | + echo "${M2_HOME}/bin" >> $GITHUB_PATH |
| 89 | + |
| 90 | + # To ensure docker containers are fully up and running we sleep 60s |
| 91 | + - name: Before script |
| 92 | + run: | |
| 93 | + source src/main/docker/env.bash |
| 94 | + docker-compose -f src/main/docker/docker-compose.yml up -d eiffel-er mongodb rabbitmq jenkins mail-server ldap ldap-seed ldap2 ldap2-seed |
| 95 | + echo 'Sleeping till Jenkins is up.' |
| 96 | + timeout 90 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST:$JENKINS_PORT/login)" != "200" ]]; do sleep 5; done' || false |
| 97 | + git clone --depth=50 --branch=master https://github.com/eiffel-community/eiffel-intelligence.git |
| 98 | + cd eiffel-intelligence |
| 99 | + chmod +x pom.xml |
| 100 | + mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V |
| 101 | + export EIFFEL_WAR=$(ls target/*.war) |
| 102 | + java -Dspring.config.additional-location=file:../src/integrationtest/resources/integration-test.properties -Dserver.port=${EI_BACKEND_PORT} -jar ${EIFFEL_WAR} & |
| 103 | + cd .. |
| 104 | + echo 'Sleeping till EI is up.' |
| 105 | + timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST:$EI_BACKEND_PORT/status)" != "200" ]]; do sleep 5; done' || false |
| 106 | + |
| 107 | + - name: Run Integration tests |
| 108 | + run: | |
| 109 | + mvn --version |
| 110 | + mvn verify -P integrationTest -DskipUTs -Dei.backend.instances.list.json.content="[{ 'contextPath': '', 'port': '${EI_BACKEND_PORT}', 'name': 'EI-Backend-1', 'host': 'localhost', 'https': false, 'defaultBackend': true}]" -B |
| 111 | + |
| 112 | + - name: After script |
| 113 | + run: | |
| 114 | + docker-compose -f src/main/docker/docker-compose.yml down || true |
| 115 | + fuser -k ${EI_BACKEND_PORT}/tcp |
| 116 | + |
| 117 | + reportCoverage: |
| 118 | + if: github.repository == 'eiffel-community/eiffel-intelligence-frontend' && github.event_name == 'push' |
| 119 | + # The type of runner that the job will run on |
| 120 | + runs-on: ubuntu-18.04 |
| 121 | + env: |
| 122 | + EI_BACKEND_PORT: 8099 |
| 123 | + JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64 |
| 124 | + M2_HOME: /opt/apache-maven-3.6.3 |
| 125 | + MAVEN_HOME: /opt/apache-maven-3.6.3 |
| 126 | + |
| 127 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 128 | + steps: |
| 129 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 130 | + - uses: actions/checkout@v3 |
| 131 | + |
| 132 | + # Runs a set of commands using the runners shell |
| 133 | + # Run before every job |
| 134 | + - name: Install Java |
| 135 | + run: | |
| 136 | + sudo apt-get update |
| 137 | + sudo apt-get install -y openjdk-8-jdk |
| 138 | + java -version |
| 139 | + uname -a |
| 140 | + chmod +x pom.xml |
| 141 | + mvn --version |
| 142 | + |
| 143 | + - name: Install Maven |
| 144 | + shell: bash |
| 145 | + run: | |
| 146 | + wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp |
| 147 | + tar xf /tmp/apache-maven-3.6.3-bin.tar.gz -C /opt |
| 148 | + echo "${M2_HOME}/bin" >> $GITHUB_PATH |
| 149 | + |
| 150 | + - name: Run cobertura |
| 151 | + shell: bash |
| 152 | + run: | |
| 153 | + mvn cobertura:cobertura -Dcobertura.report.format=xml -B |
| 154 | + |
| 155 | + # Generating test coverage report and publishing to Codacy |
| 156 | + - name: Run report coverage |
| 157 | + uses: codacy/codacy-coverage-reporter-action@v1 |
| 158 | + with: |
| 159 | + project-token: 4f71427f28dc44a7b762bb14f21094ea |
| 160 | + coverage-reports: target/site/cobertura/coverage.xml |
0 commit comments