From cc35ce5067181ecd75c702981f6ef2cc8b60a393 Mon Sep 17 00:00:00 2001
From: Jean-Michel Picod <jmichel@google.com>
Date: Fri, 28 Feb 2020 16:03:04 +0100
Subject: [PATCH] Create workflows for unit testing

---
 .github/workflows/cbor_test.yml    | 38 +++++++++++++++++++++++
 .github/workflows/crypto_test.yml  | 40 ++++++++++++++++++++++++
 .github/workflows/opensk_build.yml | 30 ++++++++++++++++++
 .github/workflows/opensk_test.yml  | 50 ++++++++++++++++++++++++++++++
 4 files changed, 158 insertions(+)
 create mode 100644 .github/workflows/cbor_test.yml
 create mode 100644 .github/workflows/crypto_test.yml
 create mode 100644 .github/workflows/opensk_build.yml
 create mode 100644 .github/workflows/opensk_test.yml

diff --git a/.github/workflows/cbor_test.yml b/.github/workflows/cbor_test.yml
new file mode 100644
index 0000000..37d08f8
--- /dev/null
+++ b/.github/workflows/cbor_test.yml
@@ -0,0 +1,38 @@
+---
+name: CBOR tests
+on:
+  push:
+    paths:
+      - 'libraries/cbor/**/*'
+  pull_request:
+    types: [opened, synchronize, reopened]
+
+jobs:
+  cbor_test:
+    runs-on: ubuntu-18.04
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions-rs/toolchain@v1
+        with:
+          toolchain: nightly
+          target: thumbv7em-none-eabi
+          override: true
+      - uses: actions/setup-python@v1
+        with:
+          python-version: 3.7
+      - name: Install Python dependencies
+        run: python -m pip install --upgrade pip setuptools wheel
+      - name: Set up OpenSK
+        run: ./setup.sh
+
+      - name: Unit testing of CBOR library (release mode)
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --manifest-path libraries/cbor/Cargo.toml --release --features std
+
+      - name: Unit testing of CBOR library (debug mode)
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --manifest-path libraries/cbor/Cargo.toml --features std
diff --git a/.github/workflows/crypto_test.yml b/.github/workflows/crypto_test.yml
new file mode 100644
index 0000000..da4ce37
--- /dev/null
+++ b/.github/workflows/crypto_test.yml
@@ -0,0 +1,40 @@
+---
+name: CBOR tests
+on:
+  push:
+    paths:
+      - 'libraries/crypto/**/*'
+  pull_request:
+    types: [opened, synchronize, reopened]
+
+jobs:
+  crypto_test:
+    runs-on: ubuntu-18.04
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions-rs/toolchain@v1
+        with:
+          toolchain: nightly
+          target: thumbv7em-none-eabi
+          override: true
+      - uses: actions/setup-python@v1
+        with:
+          python-version: 3.7
+      - name: Install Python dependencies
+        run: python -m pip install --upgrade pip setuptools wheel
+      - name: Set up OpenSK
+        run: ./setup.sh
+
+      - run: echo "::set-env name=RUSTFLAGS::-C target-feature=+aes"
+
+      - name: Unit testing of crypto library (release mode)
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --manifest-path libraries/crypto/Cargo.toml --release --features std,derive_debug
+
+      - name: Unit testing of crypto library (debug mode)
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --manifest-path libraries/crypto/Cargo.toml --features std,derive_debug
diff --git a/.github/workflows/opensk_build.yml b/.github/workflows/opensk_build.yml
new file mode 100644
index 0000000..91fe551
--- /dev/null
+++ b/.github/workflows/opensk_build.yml
@@ -0,0 +1,30 @@
+---
+name: OpenSK build
+on:
+  push:
+  pull_request:
+    types: [opened, synchronize, reopened]
+
+jobs:
+  build:
+    runs-on: ubuntu-18.04
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions-rs/toolchain@v1
+        with:
+          toolchain: nightly
+          target: thumbv7em-none-eabi
+          override: true
+      - uses: actions/setup-python@v1
+        with:
+          python-version: 3.7
+      - name: Install Python dependencies
+        run: python -m pip install --upgrade pip setuptools wheel
+      - name: Set up OpenSK
+        run: ./setup.sh
+
+      - name: Building OpenSK
+        uses: actions-rs/cargo@v1
+        with:
+          command: build
+          args: --release --target=thumbv7em-none-eabi --features with_ctap1
diff --git a/.github/workflows/opensk_test.yml b/.github/workflows/opensk_test.yml
new file mode 100644
index 0000000..1b40727
--- /dev/null
+++ b/.github/workflows/opensk_test.yml
@@ -0,0 +1,50 @@
+---
+name: OpenSK tests
+on:
+  push:
+    paths:
+      - 'src/**/*.rs'
+  pull_request:
+    types: [opened, synchronize, reopened]
+
+jobs:
+  ctap2_test:
+    runs-on: ubuntu-18.04
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions-rs/toolchain@v1
+        with:
+          toolchain: nightly
+          target: thumbv7em-none-eabi
+          override: true
+      - uses: actions/setup-python@v1
+        with:
+          python-version: 3.7
+      - name: Install Python dependencies
+        run: python -m pip install --upgrade pip setuptools wheel
+      - name: Set up OpenSK
+        run: ./setup.sh
+
+      - name: Unit testing of CTAP2 (release mode)
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --release --features std
+
+      - name: Unit testing of CTAP2 (debug mode)
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --features std
+
+      - name: Unit testing of CTAP2 (release mode + CTAP1)
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --features std,with_ctap1
+
+      - name: Unit testing of CTAP2 (debug mode + CTAP1)
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --features std,with_ctap1
-- 
GitLab