You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2022/11/15 09:28:15 UTC

[cayenne] 02/02: Enable GitHub actions

This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch STABLE-4.1
in repository https://gitbox.apache.org/repos/asf/cayenne.git

commit c4afac866e0666df4387d777d7f73eda28dc23d1
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Tue Nov 15 12:19:58 2022 +0300

    Enable GitHub actions
---
 .github/actions/export-pom-version/action.yml      | 13 ++++
 .github/actions/export-pom-version/bash.sh         | 11 +++
 .../maven-settings.xml                             | 10 +--
 .github/workflows/verify-deploy-on-push-4.1.yml    | 81 ++++++++++++++++++++++
 .github/workflows/verify-on-pr-4.1.yml             | 50 +++++++++++++
 .travis.yml                                        | 60 ----------------
 6 files changed, 160 insertions(+), 65 deletions(-)

diff --git a/.github/actions/export-pom-version/action.yml b/.github/actions/export-pom-version/action.yml
new file mode 100644
index 000000000..69cce0ca5
--- /dev/null
+++ b/.github/actions/export-pom-version/action.yml
@@ -0,0 +1,13 @@
+name: Pom version
+description: Gets version from the pom.xml file
+
+runs:
+  using: "composite"
+  steps:
+    - id: set-up
+      run: chmod +x $GITHUB_ACTION_PATH/bash.sh
+      shell: bash
+
+    - id: get-pom-version
+      run: $GITHUB_ACTION_PATH/bash.sh
+      shell: bash
\ No newline at end of file
diff --git a/.github/actions/export-pom-version/bash.sh b/.github/actions/export-pom-version/bash.sh
new file mode 100644
index 000000000..1ed9a6bee
--- /dev/null
+++ b/.github/actions/export-pom-version/bash.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+function get_pom_version {
+  awk -F '<[^>]*>' '/<dependencies>/,/<\/dependencies>/{next} /<plugins>/,/<\/plugins>/{next} /<version>/ {$1=$1; gsub(/ /,"") $0; print}' pom.xml
+}
+
+VERSION=$(get_pom_version)
+echo "pom.xml version: $VERSION"
+
+# export VERSION to the GitHub env
+echo "POM_VERSION=$VERSION" >> "$GITHUB_ENV"
\ No newline at end of file
diff --git a/.travis-mvn-settings.xml b/.github/maven-settings.xml
similarity index 71%
rename from .travis-mvn-settings.xml
rename to .github/maven-settings.xml
index c2ea8e326..7e77f806b 100644
--- a/.travis-mvn-settings.xml
+++ b/.github/maven-settings.xml
@@ -7,7 +7,7 @@
   ~  "License"); you may not use this file except in compliance
   ~  with the License.  You may obtain a copy of the License at
   ~
-  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~    https://www.apache.org/licenses/LICENSE-2.0
   ~
   ~  Unless required by applicable law or agreed to in writing,
   ~  software distributed under the License is distributed on an
@@ -18,13 +18,13 @@
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
 
 <!-- Maven build settings for Travis CI -->
-<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+<settings xmlns="https://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="https://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
     <servers>
         <server>
             <id>apache.snapshots.https</id>
-            <username>${env.SNAPSHOT_REPO_USERNAME}</username>
-            <password>${env.SNAPSHOT_REPO_PASSWORD}</password>
+            <username>${env.MAVEN_USERNAME}</username>
+            <password>${env.MAVEN_PASSWORD}</password>
         </server>
     </servers>
 </settings>
\ No newline at end of file
diff --git a/.github/workflows/verify-deploy-on-push-4.1.yml b/.github/workflows/verify-deploy-on-push-4.1.yml
new file mode 100644
index 000000000..9982d3658
--- /dev/null
+++ b/.github/workflows/verify-deploy-on-push-4.1.yml
@@ -0,0 +1,81 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: verify and deploy 4.1
+
+on: push
+
+env:
+  MAVEN_OPTS: -Xmx4g -Xms1g -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.count=3
+
+jobs:
+  verify:
+    runs-on: ubuntu-latest
+    name: JDK ${{ matrix.jdk }}, DB ${{ matrix.db-profile }}
+    continue-on-error: ${{ matrix.jdk == '17' }}
+    if: github.repository == 'apache/cayenne'
+
+    strategy:
+      matrix:
+        jdk: [8, 11]
+        db-profile: [hsql, h2, derby, mysql-tc, postgres-tc, sqlserver-tc]
+        include:
+          - jdk: 17
+            db-profile: postgres-tc
+      fail-fast: false # finish all jobs anyway
+
+    env:
+      JDK_VERSION: ${{ matrix.jdk }}
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v3
+
+      - name: Setup java
+        uses: actions/setup-java@v3
+        with:
+          distribution: 'temurin'
+          java-version: ${{ matrix.jdk }}
+          cache: 'maven'
+
+      - name: mvn verify ${{ matrix.db-profile }}
+        run: mvn verify -q -DcayenneTestConnection=${{ matrix.db-profile }} -DcayenneLogLevel=ERROR
+
+  deploy:
+    needs: verify
+    runs-on: ubuntu-latest
+    if: github.repository == 'apache/cayenne' && (contains(github.ref_name, 'STABLE-') || github.ref == 'refs/heads/master')
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v3
+
+      - name: Export version
+        uses: ./.github/actions/export-pom-version
+
+      - name: Setup java
+        uses: actions/setup-java@v3
+        if: contains(env.POM_VERSION, '-SNAPSHOT')
+        with:
+          distribution: 'temurin'
+          java-version: 8
+          cache: 'maven'
+
+      - name: Deploy snapshot
+        run: mvn deploy -DskipTests --settings .github/maven-settings.xml
+        if: contains(env.POM_VERSION, '-SNAPSHOT')
+        env:
+          MAVEN_USERNAME: ${{ secrets.NEXUS_USER }}
+          MAVEN_PASSWORD: ${{ secrets.NEXUS_PW }}
\ No newline at end of file
diff --git a/.github/workflows/verify-on-pr-4.1.yml b/.github/workflows/verify-on-pr-4.1.yml
new file mode 100644
index 000000000..f3c030cc9
--- /dev/null
+++ b/.github/workflows/verify-on-pr-4.1.yml
@@ -0,0 +1,50 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: verify PR 4.1
+
+on: pull_request
+
+env:
+  MAVEN_OPTS: -Xmx4g -Xms1g -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.count=3
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    name: JDK ${{ matrix.jdk }}, DB ${{ matrix.db-profile }}
+    if: github.repository == 'apache/cayenne'
+
+    strategy:
+      matrix:
+        jdk: [8, 11]
+        db-profile: [hsql, h2, derby, mysql-tc, postgres-tc, sqlserver-tc]
+      fail-fast: true
+
+    env:
+      JDK_VERSION: ${{ matrix.jdk }}
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v3
+
+      - name: Setup java
+        uses: actions/setup-java@v3
+        with:
+          distribution: 'temurin'
+          java-version: ${{ matrix.jdk }}
+          cache: 'maven'
+
+      - name: mvn verify ${{ matrix.db-profile }}
+        run: mvn verify -q -DcayenneTestConnection=${{ matrix.db-profile }} -DcayenneLogLevel=ERROR
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index f9795221e..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,60 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-language: java
-
-os: linux
-dist: bionic
-
-services:
-  - docker
-
-env:
-  jobs:
-    - DB_PROFILE=hsql
-    - DB_PROFILE=h2
-    - DB_PROFILE=derby
-    - DB_PROFILE=mysql-docker
-    - DB_PROFILE=postgres-docker
-    - DB_PROFILE=sqlserver-docker
-  global:
-    # travis encrypt -r apache/cayenne "SNAPSHOT_REPO_USERNAME='username'"
-    # travis encrypt -r apache/cayenne "SNAPSHOT_REPO_PASSWORD='password'"
-    - secure: "ssx4T8lnuLcR6bRx8BWeWRDa5IfK7RBi5CfNoFlQMoSaiiFvbW0TG+1YAqsYnvf07PfU7YJ4+6b0pG+E83Serw7TSoXehvCeCK8AzsT9/BbVpvuQVlbj/cG9rfrJcTvGyZI7p02+nVBR70XSN2qcvWQt5q2me7ZApS3unmen350="
-    - secure: "cysyR/fEtBHC26lYHGhfXYIPMaol1c1wP+r59idByE4iq71QiOffA4j1CQCAnN5Zo7QsNavz/GZoIxNif4SUcY7sW5M92a78VFVK3aYGTOBtN9jpqWDJoFc8jm5C75j3CoBe7dVFkxw3pCdMlZQ7HJj7L+GiyZ5USu6E2vD5X7A="
-
-jdk:
-  - openjdk8
-  - openjdk11
-  - openjdk-ea
-
-script:
-  - travis_wait mvn verify -q $EXCLUDE_MODULES -DcayenneTestConnection=$DB_PROFILE -DcayenneLogLevel=ERROR
-
-jobs:
-  allow_failures:
-    - jdk: openjdk-ea
-  include:
-    - stage: deploy
-      script: mvn deploy -DskipTests --settings .travis-mvn-settings.xml
-      jdk: openjdk8
-      if: type = push AND branch = STABLE-4.1 AND repo = apache/cayenne
-
-# prevent Travis from unneeded "mvn install" run
-install: true
-
-cache:
-  directories:
-    - $HOME/.m2