Browse Source

Remove travis, introduce github actions, add support for OTP-24

Sergey Prokhorov 3 years ago
parent
commit
036656a6ff
5 changed files with 76 additions and 28 deletions
  1. 59 0
      .github/workflows/ci.yml
  2. 0 24
      .travis.yml
  3. 1 1
      Makefile
  4. 15 2
      test/epgsql_SUITE.erl
  5. 1 1
      test/epgsql_cth.erl

+ 59 - 0
.github/workflows/ci.yml

@@ -0,0 +1,59 @@
+name: CI
+
+on:
+  push:
+    branches:
+      - master
+      - devel
+  pull_request:
+    branches:
+      - devel
+jobs:
+  test:
+    runs-on: ubuntu-18.04
+    strategy:
+      fail-fast: false
+      matrix:
+        pg:
+          - 10
+        otp:
+          - "24.0"
+          - "23.3"
+          - "22.3"
+          - "21.3"
+          - "20.3"
+          - "19.3"
+    # env:
+    #   PATH: ".:/usr/lib/postgresql/12/bin:$PATH"
+    env:
+      SHELL: /bin/sh            # needed for erlexec
+    steps:
+      - uses: actions/checkout@v2
+
+      - uses: erlef/setup-beam@v1
+        with:
+          otp-version: ${{matrix.otp}}
+
+      - name: Setup postgresql server with postgis
+        run: sudo apt install postgresql-${{matrix.pg}} postgresql-contrib-${{matrix.pg}} postgresql-${{matrix.pg}}-postgis-2.4 postgresql-${{matrix.pg}}-postgis-2.4-scripts
+
+      - name: elvis
+        run: make elvis
+
+      - name: Common test, eunit, coverage
+        run: PATH=$PATH:/usr/lib/postgresql/${{matrix.pg}}/bin/ make test
+
+      - name: Upload CT logs artifact
+        uses: actions/upload-artifact@v2
+        if: failure()
+        with:
+          name: ct_report_pg-${{matrix.pg}}_otp-${{matrix.otp}}
+          path: |
+            _build/test/logs/ct_run*/
+            !_build/test/logs/ct_run*/datadir
+
+      - name: Build docs
+        run: make edoc
+
+      - name: dialyzer
+        run: make dialyzer

+ 0 - 24
.travis.yml

@@ -1,24 +0,0 @@
-addons:
-  postgresql: "10"
-  apt:
-    packages:
-      - postgresql-10-postgis-2.4
-      - postgresql-10-postgis-2.4-scripts
-      - postgresql-contrib-10
-env:
-  - PATH=".:/usr/lib/postgresql/10/bin:$PATH"
-install: "true"
-language: erlang
-matrix:
-  include:
-    - otp_release: 23.3.1
-    - otp_release: 22.3
-    - otp_release: 21.3
-    - otp_release: 20.3
-    - otp_release: 19.3
-    - otp_release: 18.3
-script:
-  - '[ "$TRAVIS_OTP_RELEASE" = "18.3" ] || make elvis' # TODO: remove the guard when OTP18 support is dropped
-  - make test
-  - make edoc
-  - make dialyzer

+ 1 - 1
Makefile

@@ -4,7 +4,7 @@ MINIMAL_COVERAGE = 55
 all: compile
 
 $(REBAR):
-	wget https://github.com/erlang/rebar3/releases/download/3.13.2/rebar3
+	wget https://github.com/erlang/rebar3/releases/download/3.15.2/rebar3
 	chmod +x rebar3
 
 compile: src/epgsql_errcodes.erl $(REBAR)

+ 15 - 2
test/epgsql_SUITE.erl

@@ -376,8 +376,19 @@ connect_with_invalid_client_cert(Config) ->
     Dir = filename:join(code:lib_dir(epgsql), ?TEST_DATA_DIR),
     File = fun(Name) -> filename:join(Dir, Name) end,
     Trap = process_flag(trap_exit, true),
+    %% pre-otp23:
+    %% {error,
+    %%   {ssl_negotiation_failed,
+    %%     {tls_alert,
+    %%       {unknown_ca, "received SERVER ALERT: Fatal - Unknown CA"}}}}
+    %% otp23+:
+    %% {error,
+    %%   {sock_error,
+    %%     {tls_alert,
+    %%       {unknown_ca, "TLS client: <..> received SERVER ALERT: Fatal - Unknown CA\n"}}}}
     ?assertMatch(
-       {error, {ssl_negotiation_failed, _}},
+       {error, {Err, {tls_alert, _}}} when Err == ssl_negotiation_failed;
+                                           Err == sock_error,
        Module:connect(
          #{username => "epgsql_test_cert",
            database => "epgsql_test_db1",
@@ -388,7 +399,9 @@ connect_with_invalid_client_cert(Config) ->
                [{keyfile, File("bad-client.key")},
                 {certfile, File("bad-client.crt")}]}
         )),
-    ?assertMatch({'EXIT', _, {ssl_negotiation_failed, _}}, receive Stop -> Stop end),
+    ?assertMatch({'EXIT', _, {Err, {tls_alert, _}}} when Err == ssl_negotiation_failed;
+                                                         Err == sock_error,
+                 receive Stop -> Stop end),
     process_flag(trap_exit, Trap).
 
 connect_map(Config) ->

+ 1 - 1
test/epgsql_cth.erl

@@ -37,7 +37,7 @@ create_testdbs(Config) ->
         [Psql, Opts, "template1 < ", filename:join(?TEST_DATA_DIR, "test_schema.sql")]
     ],
     lists:foreach(fun(Cmd) ->
-        {ok, []} = exec:run(lists:flatten(Cmd), [sync])
+        {ok, []} = exec:run(lists:flatten(Cmd), [sync, stderr])
     end, Cmds).
 
 %% =============================================================================