From feacd72d6eba31f04c7f23aeaea8d4186be4700d Mon Sep 17 00:00:00 2001
From: Jean-Michel Picod <jmichel@google.com>
Date: Mon, 24 Feb 2020 19:00:51 +0100
Subject: [PATCH] Add Github workflows

These should do the checks for us.
Not an expert though so it may need a bit of tweaking before they do
what we want them to do.
---
 .github/workflows/mdlint.yml | 18 ++++++++
 .github/workflows/pylint.yml | 27 ++++++++++++
 .github/workflows/rust.yml   | 79 ++++++++++++++++++++++++++++++++++++
 3 files changed, 124 insertions(+)
 create mode 100644 .github/workflows/mdlint.yml
 create mode 100644 .github/workflows/pylint.yml
 create mode 100644 .github/workflows/rust.yml

diff --git a/.github/workflows/mdlint.yml b/.github/workflows/mdlint.yml
new file mode 100644
index 0000000..5c2db7b
--- /dev/null
+++ b/.github/workflows/mdlint.yml
@@ -0,0 +1,18 @@
+name: markdownlint
+on:
+  push:
+    paths:
+      - '**/*.md'
+      - '.markdownlint.json'
+      - '!third_party/**'
+
+jobs:
+  pylint:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: markdownlint-cli
+        uses: nosborn/github-action-markdown-cli@v1.1.1
+        with:
+          files: **/*.md
+          config_file: ".markdownlint.json"
diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml
new file mode 100644
index 0000000..929a051
--- /dev/null
+++ b/.github/workflows/pylint.yml
@@ -0,0 +1,27 @@
+name: pylint
+on:
+  push:
+    paths:
+      - '**/*.py'
+      - '.pylintrc'
+      - '!third_party/**'
+jobs:
+  pylint:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: [3.6, 3.7, 3.8]
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v1
+        with:
+          python-version: ${{ matrix.python-version }}
+      - name: Install dependencies
+        run: |
+          python -m pip install --upgrade pip setuptools wheel
+          pip install tockloader
+      - name: Test code with pylint
+        run: |
+          pip install pylint
+          pylint --rcfile=.pylintrc
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
new file mode 100644
index 0000000..0611f1f
--- /dev/null
+++ b/.github/workflows/rust.yml
@@ -0,0 +1,79 @@
+on:
+  push:
+    paths:
+      - 'examples/*.rs'
+      - 'libraries/**/*.rs'
+      - 'src/**/*.rs'
+      - 'patches/**'
+      - '**/Cargo.toml'
+      - '.cargo/config'
+      - '!third_party/**'
+
+jobs:
+  initial_setup:
+    name: Set up project
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions-rs/toolchain@v1
+        with:
+          toolchain: nightly
+          target: thumbv7em-none-eabi
+          override: true
+      - run: ./setup.sh
+
+  cargo_format_src:
+    name: Cargo format src/
+    needs: initial_setup
+    steps:
+      - uses: actions-rs/cargo@v1
+        with:
+          command: fmt
+          args: --all -- --check
+  cargo_format_cbor:
+    name: Cargo format libraries/cbor
+    needs: initial_setup
+    steps:
+      - uses: actions-rs/cargo@v1
+        working-directory: libraries/cbor
+        with:
+          command: fmt
+          args: --all -- --check
+  cargo_format_crypto:
+    name: Cargo format libraries/crypto
+    needs: initial_setup
+    steps:
+      - uses: actions-rs/cargo@v1
+        working-directory: libraries/crypto
+        with:
+          command: fmt
+          args: --all -- --check
+  cargo_check:
+    name: Cargo Check
+    needs: initial_setup
+    steps:
+      - name: Check OpenSK w/o features
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: --target thumbv7em-none-eabi --release
+      - name: Check OpenSK with_ctap1
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: --target thumbv7em-none-eabi --release --features with_ctap1
+      - name: Check OpenSK debug_ctap
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: --target thumbv7em-none-eabi --release --features debug_ctap
+      - name: Check OpenSK debug_ctap,with_ctap1
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: --target thumbv7em-none-eabi --release --features debug_ctap,with_ctap1
+      - name: Check examples
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: --target thumbv7em-none-eabi --release --examples
-- 
GitLab