From ee0db9a617668cfe3955e5c699add9299948d2de Mon Sep 17 00:00:00 2001
From: Yuki Okushi <huyuumi.dev@gmail.com>
Date: Tue, 28 Jan 2020 19:56:38 +0900
Subject: [PATCH] Tweak GitHub Actions

---
 .github/workflows/clippy.yml        | 17 +++++++
 .github/workflows/macos.yml         | 37 ++++++++++++++
 .github/workflows/main.yml          | 78 -----------------------------
 .github/workflows/windows-mingw.yml | 54 ++++++++++++++++++++
 .github/workflows/windows.yml       | 63 +++++++++++++++++++++++
 5 files changed, 171 insertions(+), 78 deletions(-)
 create mode 100644 .github/workflows/clippy.yml
 create mode 100644 .github/workflows/macos.yml
 delete mode 100644 .github/workflows/main.yml
 create mode 100644 .github/workflows/windows-mingw.yml
 create mode 100644 .github/workflows/windows.yml

diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml
new file mode 100644
index 00000000..9c90947b
--- /dev/null
+++ b/.github/workflows/clippy.yml
@@ -0,0 +1,17 @@
+on: pull_request
+
+name: Clippy Check
+jobs:
+  clippy_check:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@master
+      - uses: actions-rs/toolchain@v1
+        with:
+          toolchain: nightly
+          components: clippy
+          override: true
+      - uses: actions-rs/clippy-check@v1
+        with:
+          token: ${{ secrets.GITHUB_TOKEN }}
+          args: --all-features --all --tests
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
new file mode 100644
index 00000000..a0a07c48
--- /dev/null
+++ b/.github/workflows/macos.yml
@@ -0,0 +1,37 @@
+name: CI (macOS)
+
+on: [push, pull_request]
+
+jobs:
+  build_and_test:
+    strategy:
+      fail-fast: false
+      matrix:
+        version:
+          - stable
+          - nightly
+
+    name: ${{ matrix.version }} - x86_64-apple-darwin
+    runs-on: macos-latest
+
+    steps:
+      - uses: actions/checkout@master
+
+      - name: Install ${{ matrix.version }}
+        uses: actions-rs/toolchain@v1
+        with:
+          toolchain: ${{ matrix.version }}-x86_64-apple-darwin
+          profile: minimal
+          override: true
+
+      - name: check build
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: --all --bins --examples --tests
+
+      - name: tests
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --all --all-features --no-fail-fast -- --nocapture
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
deleted file mode 100644
index 46fc2e5d..00000000
--- a/.github/workflows/main.yml
+++ /dev/null
@@ -1,78 +0,0 @@
-name: CI
-
-on: [push, pull_request]
-
-env:
-  VCPKGRS_DYNAMIC: 1
-
-jobs:
-  build_and_test:
-    strategy:
-      fail-fast: false
-      matrix:
-        toolchain:
-          - x86_64-pc-windows-msvc
-          - x86_64-pc-windows-gnu
-          - i686-pc-windows-msvc
-          - x86_64-apple-darwin
-        version:
-          - stable
-          - nightly
-        include:
-        - toolchain: x86_64-pc-windows-msvc
-          os: windows-latest
-          arch: x64
-        - toolchain: x86_64-pc-windows-gnu
-          os: windows-latest
-        - toolchain: i686-pc-windows-msvc
-          os: windows-latest
-          arch: x86
-        - toolchain: x86_64-apple-darwin
-          os: macOS-latest
-
-    name: ${{ matrix.version }} - ${{ matrix.toolchain }}
-    runs-on: ${{ matrix.os }}
-
-    steps:
-      - uses: actions/checkout@master
-
-      - name: Install ${{ matrix.version }}
-        uses: actions-rs/toolchain@v1
-        with:
-          toolchain: ${{ matrix.version }}-${{ matrix.toolchain }}
-          default: true
-
-
-      - name: Install OpenSSL
-        if: matrix.toolchain == 'x86_64-pc-windows-msvc' || matrix.toolchain == 'i686-pc-windows-msvc'
-        run: |
-          vcpkg integrate install
-          vcpkg install openssl:${{ matrix.arch }}-windows
-
-      - name: check nightly
-        if: matrix.version == 'nightly'
-        uses: actions-rs/cargo@v1
-        with:
-          command: check
-          args: --all --benches --bins --examples --tests
-
-      - name: check stable
-        if: matrix.version == 'stable'
-        uses: actions-rs/cargo@v1
-        with:
-          command: check
-          args: --all --bins --examples --tests
-
-      - name: tests
-        if: matrix.toolchain != 'x86_64-pc-windows-gnu'
-        uses: actions-rs/cargo@v1
-        with:
-          command: test
-          args: --all --all-features -- --nocapture
-
-      - name: tests on x86_64-pc-windows-gnu
-        if: matrix.toolchain == 'x86_64-pc-windows-gnu'
-        uses: actions-rs/cargo@v1
-        with:
-          command: test
-          args: --all -- --nocapture
diff --git a/.github/workflows/windows-mingw.yml b/.github/workflows/windows-mingw.yml
new file mode 100644
index 00000000..1d23ec86
--- /dev/null
+++ b/.github/workflows/windows-mingw.yml
@@ -0,0 +1,54 @@
+name: CI (Windows-gnu)
+
+on: [push, pull_request]
+
+env:
+  OPENSSL_DIR: d:\a\_temp\msys\msys64\usr
+
+jobs:
+  build_and_test:
+    strategy:
+      fail-fast: false
+      matrix:
+        version:
+          - stable
+          - nightly
+
+    name: ${{ matrix.version }} - x86_64-pc-windows-gnu
+    runs-on: windows-latest
+
+    steps:
+      - uses: actions/checkout@master
+
+      - name: Install ${{ matrix.version }}
+        uses: actions-rs/toolchain@v1
+        with:
+          toolchain: ${{ matrix.version }}-x86_64-pc-windows-gnu
+          profile: minimal
+          override: true
+
+      - name: Install MSYS2
+        uses: numworks/setup-msys2@v1
+
+      - name: Install OpenSSL
+        run: |
+          msys2do pacman --noconfirm -S openssl-devel pkg-config
+
+      - name: Copy and check libs
+        run: |
+          Copy-Item d:\a\_temp\msys\msys64\usr\lib\libssl.dll.a d:\a\_temp\msys\msys64\usr\lib\libssl.dll
+          Copy-Item d:\a\_temp\msys\msys64\usr\lib\libcrypto.dll.a d:\a\_temp\msys\msys64\usr\lib\libcrypto.dll
+          Get-ChildItem d:\a\_temp\msys\msys64\usr\lib
+          Get-ChildItem d:\a\_temp\msys\msys64\usr
+
+      - name: check build
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: --all --bins --examples --tests
+
+      - name: tests
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --all --all-features --no-fail-fast -- --nocapture
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
new file mode 100644
index 00000000..92ce985d
--- /dev/null
+++ b/.github/workflows/windows.yml
@@ -0,0 +1,63 @@
+name: CI (Windows)
+
+on: [push, pull_request]
+
+env:
+  VCPKGRS_DYNAMIC: 1
+
+jobs:
+  build_and_test:
+    strategy:
+      fail-fast: false
+      matrix:
+        version:
+          - stable
+          - nightly
+        target:
+          - x86_64-pc-windows-msvc
+          - i686-pc-windows-msvc
+
+    name: ${{ matrix.version }} - ${{ matrix.target }}
+    runs-on: windows-latest
+
+    steps:
+      - uses: actions/checkout@master
+
+      - name: Install ${{ matrix.version }}
+        uses: actions-rs/toolchain@v1
+        with:
+          toolchain: ${{ matrix.version }}-${{ matrix.target }}
+          profile: minimal
+          override: true
+
+      - name: Install OpenSSL (x64)
+        if: matrix.target == 'x86_64-pc-windows-msvc'
+        run: |
+          vcpkg integrate install
+          vcpkg install openssl:x64-windows
+          Get-ChildItem C:\vcpkg\installed\x64-windows\bin
+          Get-ChildItem C:\vcpkg\installed\x64-windows\lib
+          Copy-Item C:\vcpkg\installed\x64-windows\bin\libcrypto-1_1-x64.dll C:\vcpkg\installed\x64-windows\bin\libcrypto.dll
+          Copy-Item C:\vcpkg\installed\x64-windows\bin\libssl-1_1-x64.dll C:\vcpkg\installed\x64-windows\bin\libssl.dll
+
+      - name: Install OpenSSL (x86)
+        if: matrix.target == 'i686-pc-windows-msvc'
+        run: |
+          vcpkg integrate install
+          vcpkg install openssl:x86-windows
+          Get-ChildItem C:\vcpkg\installed\x86-windows\bin
+          Get-ChildItem C:\vcpkg\installed\x86-windows\lib
+          Copy-Item C:\vcpkg\installed\x86-windows\bin\libcrypto-1_1.dll C:\vcpkg\installed\x86-windows\bin\libcrypto.dll
+          Copy-Item C:\vcpkg\installed\x86-windows\bin\libssl-1_1.dll C:\vcpkg\installed\x86-windows\bin\libssl.dll
+
+      - name: check build
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: --all --bins --examples --tests
+
+      - name: tests
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --all --all-features --no-fail-fast -- --nocapture