Skip to content

Commit

Permalink
ci: expect node.js on build machine (#18891)
Browse files Browse the repository at this point in the history
  • Loading branch information
teleivo authored Oct 23, 2024
1 parent ff3df98 commit c0304f6
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 133 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ on:
branches:
- master
schedule:
- cron: '0 12 * * *'
- cron: "0 12 * * *"
concurrency:
group: ${{ github.workflow}}-${{ github.ref }}
cancel-in-progress: true
group: ${{ github.workflow}}-${{ github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze
Expand All @@ -27,7 +27,7 @@ jobs:
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: [ 'java' ]
language: ["java"]
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

Expand Down Expand Up @@ -58,9 +58,9 @@ jobs:
config-file: ./.github/codeql/codeql-config.yml

- name: Build core
run: mvn clean install -f ./dhis-2/pom.xml --batch-mode --no-transfer-progress -Pdev -DskipTests=true -Dmaven.javadoc.skip=true -V
run: mvn clean install -f ./dhis-2/pom.xml --batch-mode --no-transfer-progress -DskipTests=true -Dmaven.javadoc.skip=true -V
- name: Build web
run: mvn clean install -f ./dhis-2/dhis-web/pom.xml --batch-mode --no-transfer-progress -Pdev -DskipTests=true -Dmaven.javadoc.skip=true -V
run: mvn clean install -f ./dhis-2/dhis-web/pom.xml --batch-mode --no-transfer-progress -DskipTests=true -Dmaven.javadoc.skip=true -V

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
19 changes: 9 additions & 10 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
- master
pull_request:
concurrency:
group: ${{ github.workflow}}-${{ github.ref }}
cancel-in-progress: true
group: ${{ github.workflow}}-${{ github.ref }}
cancel-in-progress: true
jobs:
unit-test:
runs-on: ubuntu-latest
Expand All @@ -21,8 +21,8 @@ jobs:
java-version: 11
distribution: temurin
cache: maven
- name: Test core # NOTE: dhis-2/pom.xml needs to be installed as built artifacts are needed by dhis-web
run: mvn clean install --threads 2C --batch-mode --no-transfer-progress --update-snapshots -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty
- name: Run unit tests # NOTE: dhis-2/pom.xml needs to be installed as built artifacts are needed by dhis-web
run: mvn clean install --threads 2C --batch-mode --no-transfer-progress --update-snapshots -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty --activate-profiles unit-test
timeout-minutes: 30
- name: Report coverage to codecov
uses: codecov/codecov-action@v3
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
distribution: temurin
cache: maven
- name: Run integration tests
run: mvn clean verify --threads 2C --batch-mode --no-transfer-progress -Pintegration -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty
run: mvn clean test --threads 2C --batch-mode --no-transfer-progress -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty --activate-profiles integration-test
timeout-minutes: 30
- uses: actions/upload-artifact@v4
name: Upload test logs on failure
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
distribution: temurin
cache: maven
- name: Run integration h2 tests
run: mvn clean verify --threads 2C --batch-mode --no-transfer-progress -PintegrationH2 -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty
run: mvn clean test --threads 2C --batch-mode --no-transfer-progress -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty --activate-profiles integration-h2-test
timeout-minutes: 30
- uses: actions/upload-artifact@v4
name: Upload test logs on failure
Expand Down Expand Up @@ -167,12 +167,11 @@ jobs:
contains(needs.*.result, 'failure') &&
github.ref == 'refs/heads/master'
needs: [ unit-test, integration-test, integration-h2-test ]
needs: [unit-test, integration-test, integration-h2-test]
steps:
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_BACKEND_WEBHOOK }}
SLACK_CHANNEL: 'team-backend'
SLACK_CHANNEL: "team-backend"
SLACK_MESSAGE: "Latest test run on master failed and needs investigation :detective-duck:. \n Commit message: ${{ github.event.head_commit.message }}"
SLACK_COLOR: '#ff0000'

SLACK_COLOR: "#ff0000"
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ You'll need the following software to run DHIS2 on your machine:

- Java 8
- Maven
- Node.js at least v20 (used to bundle web apps)
- Tomcat

## Fork
Expand Down
4 changes: 2 additions & 2 deletions dhis-2/build-nocompr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Requires maven to be on the classpath
# Invokes the dev profile which skips tests and disables compression of war artifacts for a speedy build

mvn clean install --batch-mode --no-transfer-progress -Pdev
mvn clean install --batch-mode --no-transfer-progress -Pdev -f dhis-web/pom.xml -U
mvn clean install --batch-mode --no-transfer-progress
mvn clean install --batch-mode --no-transfer-progress -f dhis-web/pom.xml -U
2 changes: 1 addition & 1 deletion dhis-2/dhis-test-coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
<goals>
<goal>report-aggregate</goal>
</goals>
<phase>verify</phase>
<phase>test</phase>
</execution>
</executions>
</plugin>
Expand Down
67 changes: 33 additions & 34 deletions dhis-2/dhis-web/dhis-web-apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,56 +18,55 @@

<build>
<finalName>dhis-web-apps</finalName>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- this template is only needed by bundle-apps.js to generate the dhis-web-apps/index.html -->
<packagingExcludes>dhis-web-apps/template.html</packagingExcludes>
<archive>
<compress>true</compress>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<!-- nodejs is expected to be present to clone bundled apps -->
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<installDirectory>target</installDirectory>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>bundle-apps</argument>
</arguments>
<environmentVariables>
<BUILD_DIR>${project.build.directory}</BUILD_DIR>
<ARTIFACT_ID>${project.artifactId}</ARTIFACT_ID>
<ARTIFACT_ID>dhis-web-apps</ARTIFACT_ID>
<APPS>./apps-to-bundle.json</APPS>
<DEFAULT_BRANCH>master</DEFAULT_BRANCH>
</environmentVariables>
</configuration>
<executions>

<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v16.13.2</nodeVersion>
</configuration>
</execution>

<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
</execution>

<execution>
<id>clone apps</id>
<id>bundle-apps</id>
<goals>
<goal>npm</goal>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>run bundle-apps</arguments>
</configuration>
<phase>prepare-package</phase>
</execution>

</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
110 changes: 42 additions & 68 deletions dhis-2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@
<packaging>pom</packaging>
<name>DHIS 2</name>

<description>The District Health Information System 2 deals with
aggregating and reporting statistical health data. The goal is to allow users to analyze
and use this data to guide local action. The system is based around an goals of empowering
users, by allowing them to decide what to register and report data for.</description>
<url>http://dhis2.org</url>
<description>DHIS2 is a free and open-source software platform for collecting, managing,
analyzing, and sharing data. It supports online and offline data capture via web and mobile
devices, and includes built-in features for data validation and visualization. The generic DHIS2
data model supports both routine aggregate/statistical data collection and individual/event
data, and can be applied to use cases in any sector, allowing decentralized access to data
throughout an organizational hierarchy. DHIS2 is fully customizable through the user interface
without the need for coding skills, and can be extended with custom applications, scripts, and
integrations. Each DHIS2 instance and the data stored within it are locally owned and managed.

DHIS2 is designed and developed by the HISP Centre at University of Oslo, with the goal of
strengthening governance systems in low- and middle-income countries. It is shared as a Digital
Public Good.</description>
<url>https://dhis2.org</url>

<organization>
<name>UiO</name>
Expand Down Expand Up @@ -79,10 +87,6 @@
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<surefireArgLine>-Xmx2024m --illegal-access=permit</surefireArgLine>

<!-- Needed so we can disable running tests when the default profile
is used (activated by default). It does not honor -DskipTests otherwise https://maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-tests.html -->
<skipTests>false</skipTests>

<!-- *Dependencies* -->

<!-- DHIS2 Rule Engine -->
Expand Down Expand Up @@ -229,6 +233,7 @@
<!-- Maven plugin versions -->
<maven-surefire-plugin.version>3.5.1</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<maven-exec-plugin.version>3.4.1</maven-exec-plugin.version>
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
<maven-failsafe-plugin.version>3.5.1</maven-failsafe-plugin.version>
<maven-javadoc-plugin.version>3.10.1</maven-javadoc-plugin.version>
Expand Down Expand Up @@ -1903,6 +1908,16 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${maven-exec-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand Down Expand Up @@ -2105,6 +2120,18 @@ jasperreports.version=${jasperreports.version}
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<!-- disable the jacoco coverage agent if we skip running tests -->
<configuration>
<skip>${skipTests}</skip>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
Expand Down Expand Up @@ -2230,14 +2257,6 @@ jasperreports.version=${jasperreports.version}
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<!-- <build><sourceDirectory> cannot be set in a profile, so it needs
Expand Down Expand Up @@ -2266,13 +2285,9 @@ jasperreports.version=${jasperreports.version}
</reporting>

<profiles>

<!-- Default profile will run all unit tests, not integration tests -->
<!-- runs all unit tests -->
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<id>unit-test</id>
<build>
<plugins>
<plugin>
Expand All @@ -2297,10 +2312,9 @@ jasperreports.version=${jasperreports.version}
</build>
</profile>

<!-- Integration test profile, runs all integrations tests, not unit
tests -->
<!-- runs all integration tests using Postgres DB -->
<profile>
<id>integration</id>
<id>integration-test</id>
<build>
<plugins>
<plugin>
Expand All @@ -2323,10 +2337,9 @@ jasperreports.version=${jasperreports.version}
</build>
</profile>

<!-- IntegrationH2 test profile, this runs all the integrations tests
with H2, but not the unit tests -->
<!-- runs all integrations tests using H2 in-memory DB -->
<profile>
<id>integrationH2</id>
<id>integration-h2-test</id>
<build>
<plugins>
<plugin>
Expand All @@ -2348,43 +2361,6 @@ jasperreports.version=${jasperreports.version}
</plugins>
</build>
</profile>

<profile>
<id>dev</id>
<properties>
<skipTests>true</skipTests>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
<trimStackTrace>false</trimStackTrace>
<argLine>@{argLine} ${surefireArgLine}</argLine>
<excludedGroups>integration,integrationH2</excludedGroups>
</configuration>
</plugin>
<plugin>
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
<version>${jrebel-x-maven-plugin.version}</version>
<executions>
<execution>
<id>generate-rebel-xml</id>
<goals>
<goal>generate</goal>
</goals>
<phase>process-resources</phase>
<configuration/>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>javadoc</id>
<properties>
Expand Down Expand Up @@ -2412,7 +2388,5 @@ jasperreports.version=${jasperreports.version}
</plugins>
</build>
</profile>

</profiles>

</project>
Loading

0 comments on commit c0304f6

Please sign in to comment.