diff --git a/.github/actions/prepare-test-env/action.yml b/.github/actions/prepare-test-env/action.yml new file mode 100644 index 00000000..49437313 --- /dev/null +++ b/.github/actions/prepare-test-env/action.yml @@ -0,0 +1,15 @@ +name: "Prepare test environment" +description: "Prepares test environment" + +runs: + using: "composite" + steps: + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: '${{ env.GO_VERSION }}' + + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: '${{ env.PYTHON_VERSION }}' \ No newline at end of file diff --git a/.github/actions/static-code-check/action.yml b/.github/actions/static-code-check/action.yml new file mode 100644 index 00000000..14e9300c --- /dev/null +++ b/.github/actions/static-code-check/action.yml @@ -0,0 +1,30 @@ +name: "Run static code check" +description: "Performs static code checks." + +runs: + using: "composite" + steps: + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install tests requirements + run: | + pip3 install -r test/requirements.txt + shell: bash + + - name: Log versions + run: | + go version + shell: bash + + - name: Go Linter + uses: golangci/golangci-lint-action@v3 + with: + args: --config=golangci-lint.yml --out-${NO_FUTURE}format colored-line-number + skip-cache: true + + - name: Python Linter + run: python3 -m flake8 test + shell: bash \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 263e7db8..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: tests -on: - pull_request: - branches: - - master - -jobs: - test: - name: Run tests - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - name: Set up Go 1.16 - uses: actions/setup-go@v2 - with: - go-version: 1.16 - id: go - - name: Check out code into the Go module directory - uses: actions/checkout@master - - name: Running go tests - env: - GO111MODULE: on - run: make test - - examples: - name: Build examples - runs-on: ubuntu-latest - steps: - - name: Set up Go 1.16 - uses: actions/setup-go@v2 - with: - go-version: 1.16 - id: go - - name: Check out code into the Go module directory - uses: actions/checkout@master - - name: Building go examples - env: - GO111MODULE: on - run: ./_example/build.sh - - lint: - name: Run lint checks - runs-on: ubuntu-latest - steps: - - name: Set up Go 1.16 - uses: actions/setup-go@v2 - with: - go-version: 1.16 - id: go - - name: Check out code into the Go module directory - uses: actions/checkout@master - - name: Download golangci-lint - run: | - wget https://github.com/golangci/golangci-lint/releases/download/v1.31.0/golangci-lint-1.31.0-linux-amd64.tar.gz - tar -xvf ./golangci-lint-1.31.0-linux-amd64.tar.gz - - name: Running golangci-lint - env: - GO111MODULE: on - GOPATH: /home/runner/work/ - run: GOCILINT=./golangci-lint-1.31.0-linux-amd64/golangci-lint make lint diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..647c51b6 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,32 @@ +--- +name: Tests + +on: + push: + branches-ignore: + - 'master' + pull_request: + pull_request_target: + types: [labeled] + +env: + GO_VERSION: 1.14 + PYTHON_VERSION: '3.x' + +jobs: + tests: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@master + + - name: Prepare env + uses: ./.github/actions/prepare-test-env + + - name: Static code check + uses: ./.github/actions/static-code-check + + - name: Unit tests + run: make test + + - name: Integration tests + run: make integration \ No newline at end of file diff --git a/golangci-lint.yml b/golangci-lint.yml new file mode 100644 index 00000000..54dce5bc --- /dev/null +++ b/golangci-lint.yml @@ -0,0 +1,26 @@ +run: + timeout: 3m + +linters: + disable-all: true + enable: + - lll + - govet + - gofmt + - stylecheck + +linters-settings: + lll: + line-length: 100 + tab-width: 4 + gofmt: + simplify: false + stylecheck: +# Temporary disable "Poorly chosen identifier" check. + checks: ["all", "-ST1003"] + +issues: + exclude-rules: + - linters: + - lll + source: "\t?// (see )?https://" diff --git a/test/requirements.txt b/test/requirements.txt new file mode 100644 index 00000000..c4a360e9 --- /dev/null +++ b/test/requirements.txt @@ -0,0 +1,5 @@ +pytest==6.2.5 +flake8==3.8.1 +flake8-unused-arguments==0.0.6 +flake8-isort==4.0.0 +codespell==2.2.1 \ No newline at end of file