Repository: datanymizer/datanymizer (language: rust)

Issue:
Set up CI
Set up GitHub Actions to run these commands:
- [x] check
- [x] fmt
- [x] build 
- [x] clippy 
- [x] test
- [x] audit


Discussion / hints:

Fix patch:
diff --git a/.codecov.yml b/.codecov.yml
new file mode 100644
index 00000000..022912ee
--- /dev/null
+++ b/.codecov.yml
@@ -0,0 +1,5 @@
+coverage:
+  status:
+    project:
+      default:
+        target: 75%
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..4517a938
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.yml]
+indent_size = 2
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..78001022
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+*.rs diff=rust
+*.md diff=markdown
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 00000000..ea681995
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,17 @@
+<!--
+Thank you for your pull request. Please provide a description above and review
+the requirements below.
+
+Bug fixes and new features should include tests.
+-->
+
+<!-- _Please make sure to review and check all of these items:_ -->
+
+#### ✓ Checklist:
+<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->
+
+- [ ] This PR has been added to [CHANGELOG.md](https://github.com/datanymizer/datanymizer/blob/master/CHANGELOG.md) (at the top of the list);
+- [ ] Tests for the changes have been added (for bug fixes / features);
+- [ ] Docs have been added / updated (for bug fixes / features).
+
+<!-- _NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open._ -->
diff --git a/.github/actions-rs/grcov.yml b/.github/actions-rs/grcov.yml
new file mode 100644
index 00000000..a27370d7
--- /dev/null
+++ b/.github/actions-rs/grcov.yml
@@ -0,0 +1,3 @@
+llvm: true
+output-type: lcov
+output-file: ./lcov.info
diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml
new file mode 100644
index 00000000..8fcaffd1
--- /dev/null
+++ b/.github/workflows/audit.yml
@@ -0,0 +1,12 @@
+name: Audit
+on:
+  schedule:
+    - cron: '0 0 * * *'
+jobs:
+  audit:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v1
+      - uses: actions-rs/audit-check@v1
+        with:
+          token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 00000000..7dc26757
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,206 @@
+# Github workflow files do not support YAML anchors.
+name: CI
+on:
+  push:
+    branches:
+      - master
+  pull_request:
+
+env:
+  CARGO_TERM_COLOR: always
+
+jobs:
+  check:
+    name: Check / Linux
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v1
+      - uses: actions-rs/toolchain@v1
+        id: toolchain
+        with:
+          profile: minimal
+          toolchain: stable
+      - name: Chown cargo registry because of caching
+        run: sudo chown -R runner ~/.cargo/registry
+      - name: Cache cargo registry and target
+        uses: actions/cache@v2
+        with:
+          path: |
+            ~/.cargo/registry
+            target
+          key: linux-check-${{ steps.toolchain.outputs.rustc_hash }}-cargo-${{ hashFiles('**/Cargo.lock') }}
+      - name: Check
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+      - name: Cleanup for caching
+        uses: actions-rs/cargo@v1
+        with:
+          command: clean
+          args: --package pg_datanymizer
+        if: steps.cache-target.outputs.cache-hit != 'true'
+
+  fmt:
+    name: Rustfmt / Linux
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v1
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          components: rustfmt
+      - uses: actions-rs/cargo@v1
+        with:
+          command: fmt
+          args: --all -- --check
+
+  clippy:
+    name: Clippy / Linux
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v1
+      - uses: actions-rs/toolchain@v1
+        id: toolchain
+        with:
+          profile: minimal
+          toolchain: stable
+          components: clippy
+      - name: Chown cargo registry because of caching
+        run: sudo chown -R runner ~/.cargo/registry
+      - name: Cache cargo registry and target
+        uses: actions/cache@v2
+        with:
+          path: |
+            ~/.cargo/registry
+            target
+          key: clippy-linux-${{ steps.toolchain.outputs.rustc_hash }}-cargo-${{ hashFiles('**/Cargo.lock') }}
+      - name: Check with Clippy
+        uses: actions-rs/cargo@v1
+        with:
+          command: clippy
+          args: -- -D warnings
+      - name: Cleanup for caching
+        uses: actions-rs/cargo@v1
+        with:
+          command: clean
+          args: --package pg_datanymizer
+        if: steps.cache-target.outputs.cache-hit != 'true'
+
+  test:
+    name: Test and coverage / Linux
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v1
+      - uses: actions-rs/toolchain@v1
+        id: toolchain
+        with:
+          profile: minimal
+          toolchain: nightly
+          override: true
+      - name: Chown cargo registry because of caching
+        run: sudo chown -R runner ~/.cargo/registry
+      - name: Set grcov version
+        run: echo "GRCOV_VERSION=$(cargo search --limit 1 grcov | head -n1 | cut -d '"' -f2)" >> $GITHUB_ENV
+      - name: Cache cargo registry, target, and grcov binary
+        id: test-grcov
+        uses: actions/cache@v2
+        with:
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/bin/grcov
+            target
+          key: grcov-${{ steps.toolchain.outputs.rustc_hash }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ env.GRCOV_VERSION }}
+      - name: Install grcov
+        run: |
+          cargo install --version $GRCOV_VERSION grcov
+        if: steps.test-grcov.outputs.cache-hit != 'true'
+      - name: Clean coverage
+        run: |
+          rm -f target/debug/deps/*.gcda
+          rm -f target/debug/deps/*.gcno
+      - name: Run tests
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --all-features --no-fail-fast
+        env:
+          CARGO_INCREMENTAL: '0'
+          RUSTFLAGS: |
+            -Zprofile -Zpanic_abort_tests -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort
+      - uses: actions-rs/grcov@v0.1
+      - uses: codecov/codecov-action@v1
+        with:
+          file: ./lcov.info
+      - name: Cleanup for caching
+        uses: actions-rs/cargo@v1
+        with:
+          command: clean
+          args: --package pg_datanymizer
+        if: steps.cache-target.outputs.cache-hit != 'true'
+
+  linux_build:
+    name: Build / Linux
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v1
+      - uses: actions-rs/toolchain@v1
+        id: toolchain
+        with:
+          profile: minimal
+          toolchain: stable
+      - name: Chown cargo registry because of caching
+        run: sudo chown -R runner ~/.cargo/registry
+      - name: Cache cargo registry and target
+        uses: actions/cache@v2
+        with:
+          path: |
+            ~/.cargo/registry
+            target
+          key: build-linux-${{ steps.toolchain.outputs.rustc_hash }}-cargo-${{ hashFiles('**/Cargo.lock') }}
+      - name: Build
+        uses: actions-rs/cargo@v1
+        with:
+          command: build
+      - name: Cleanup for caching
+        uses: actions-rs/cargo@v1
+        with:
+          command: clean
+          args: --package pg_datanymizer
+        if: steps.cache-target.outputs.cache-hit != 'true'
+
+  windows_build:
+    name: Build / Windows
+    runs-on: windows-latest
+    steps:
+      - uses: actions/checkout@v1
+      - uses: actions-rs/toolchain@v1
+        id: toolchain
+        with:
+          profile: minimal
+          toolchain: stable
+      - name: Cache cargo registry and target
+        uses: actions/cache@v2
+        with:
+          path: |
+            ~/.cargo/registry
+            target
+          key: build-windows-${{ steps.toolchain.outputs.rustc_hash }}-cargo-${{ hashFiles('**/Cargo.lock') }}
+      - name: Build
+        uses: actions-rs/cargo@v1
+        with:
+          command: build
+      - name: Cleanup for caching
+        uses: actions-rs/cargo@v1
+        with:
+          command: clean
+          args: --package pg_datanymizer
+        if: steps.cache-target.outputs.cache-hit != 'true'
+
+  docker_build:
+    name: Build / Docker
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v1
+      - name: Build
+        run: docker build --target builder .
diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml
new file mode 100644
index 00000000..5c4a03a6
--- /dev/null
+++ b/.github/workflows/linters.yml
@@ -0,0 +1,11 @@
+name: Linters
+on: pull_request
+jobs:
+  misspell:
+    name: linters / misspell
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v1
+      - uses: reviewdog/action-misspell@v1
+        with:
+          locale: "US"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eb17c952..202eaf49 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ### 🚀 Added
 
 ### ⚙️ Changed
+- Set up CI [#12](https://github.com/datanymizer/datanymizer/pull/12) ([@mgrachev](https://github.com/mgrachev))
 - Rename `pg_dump_faker` to `pg_datanymizer` [#11](https://github.com/datanymizer/datanymizer/pull/11) ([@mgrachev](https://github.com/mgrachev))
 
-### 🛠 Fixed
\ No newline at end of file
+### 🛠 Fixed
diff --git a/README.md b/README.md
index 855ea48b..b9efe94c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,10 @@
 # [Data]nymizer
 
+![](https://github.com/datanymizer/datanymizer/workflows/CI/badge.svg)
+![](https://img.shields.io/github/license/datanymizer/datanymizer)
+![](https://img.shields.io/github/v/release/datanymizer/datanymizer)
+[![](https://codecov.io/gh/datanymizer/datanymizer/branch/main/graph/badge.svg)](https://codecov.io/gh/datanymizer/datanymizer)
+
 Simple data anonymizer with flexible rules.
 
 ## How it works
diff --git a/datanymizer_engine/src/transformers/phone/transformer.rs b/datanymizer_engine/src/transformers/phone/transformer.rs
index 751fde7f..23a51ce3 100644
--- a/datanymizer_engine/src/transformers/phone/transformer.rs
+++ b/datanymizer_engine/src/transformers/phone/transformer.rs
@@ -166,12 +166,12 @@ mod tests {
             uniq: true
         "#;
         let transformer: Transformers = serde_yaml::from_str(config).unwrap();
-    
+
         let mut phones: Vec<TransformResult> = vec![];
         for _ in 0..5 {
             phones.push(transformer.transform("field", "value", &None));
         }
-    
+
         assert!(phones.iter().any(|x| x.is_ok()))
     }
 }


Test patch: