git.delta.rocks / unique-network / refs/commits / a22c270fb3d4

difftreelog

tests: split integration tests and unit test into separate workflows

Alexander Aksenov2022-08-22parent: #997ec5a.patch.diff
in: master

2 files changed

modified.docker/Dockerfile-chain-dev-unitdiffbeforeafterboth
2323
24WORKDIR /dev_chain24WORKDIR /dev_chain
2525
26RUN cargo test --features=limit-testing26CMD cargo test --features=limit-testing
2727
added.github/workflows/unit-test.ymldiffbeforeafterboth
--- /dev/null
+++ b/.github/workflows/unit-test.yml
@@ -0,0 +1,85 @@
+name: unit tests
+
+# Controls when the action will run.
+on:
+ # Triggers the workflow on push or pull request events but only for the master branch
+  pull_request:
+    branches:
+      - develop
+      - master
+    types:
+      - opened
+      - reopened
+      - synchronize   #commit(s) pushed to the pull request
+      - ready_for_review
+
+  # Allows you to run this workflow manually from the Actions tab
+  workflow_dispatch:
+
+concurrency: 
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+  
+  unit_tests:
+    # The type of runner that the job will run on
+    runs-on: [self-hosted-ci,medium]
+    timeout-minutes: 1380
+
+    name: unit tests ${{ GITHUB_REF }}
+
+
+    continue-on-error: true         #Do not stop testing of matrix runs failed.  As it decided during PR review - it required 50/50& Let's check it with false.
+
+
+    steps:
+      - name: Skip if pull request is in Draft
+        # `if: github.event.pull_request.draft == true` should be kept here, at
+        # the step level, rather than at the job level. The latter is not
+        # recommended because when the PR is moved from "Draft" to "Ready to
+        # review" the workflow will immediately be passing (since it was skipped),
+        # even though it hasn't actually ran, since it takes a few seconds for
+        # the workflow to start. This is also disclosed in:
+        # https://github.community/t/dont-run-actions-on-draft-pull-requests/16817/17
+        # That scenario would open an opportunity for the check to be bypassed:
+        # 1. Get your PR approved
+        # 2. Move it to Draft
+        # 3. Push whatever commits you want
+        # 4. Move it to "Ready for review"; now the workflow is passing (it was
+        #    skipped) and "Check reviews" is also passing (it won't be updated
+        #    until the workflow is finished)
+        if: github.event.pull_request.draft == true
+        run: exit 1
+
+      - name: Clean Workspace
+        uses: AutoModality/action-clean@v1.1.0
+
+      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+      - uses: actions/checkout@v3
+        with:
+          ref: ${{ github.head_ref }}  #Checking out head commit
+
+      - name: Read .env file
+        uses: xom9ikk/dotenv@v1.0.2
+
+      - name: Generate ENV related extend file for docker-compose
+        uses: cuchi/jinja2-action@v1.2.0
+        with:
+          template: .docker/docker-compose.tmp-unit.j2
+          output_file: .docker/docker-compose.unit.yml
+          variables: |
+            RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
+            FEATURE=${{ matrix.features }}
+    
+
+      - name: Show build configuration
+        run: cat .docker/docker-compose.unit.yml
+
+      - name: Build the stack
+        run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.unit.yml" up --build  --force-recreate --timeout 300 --remove-orphans --exit-code-from node-dev
+
+      - name: Stop running containers
+        if: always()                   # run this step always
+        run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.unit.yml" down