From 75941bcaf982ac6c6d07d37481feafb66a47a17f Mon Sep 17 00:00:00 2001 From: danijelTxFusion Date: Wed, 10 Jan 2024 10:34:44 +0100 Subject: [PATCH] ci: add test and validation pipeline --- .github/workflows/publish.yaml | 2 +- .github/workflows/test.yml | 38 +++++++++++++++++ .github/workflows/validate.yml | 74 ++++++++++++++++++++++++++++++++++ requirements.txt | 3 +- 4 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 .github/workflows/validate.yml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index bc2375b..0b6a3d5 100755 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -15,7 +15,7 @@ jobs: - name: Set up Python 3 uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: '3.10' cache: 'pip' # caching pip dependencies - name: Prepare build run: python3 -m pip install --upgrade build diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6039bac --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,38 @@ +name: Run tests +on: + workflow_dispatch: + pull_request: + branch: main + types: [ opened, reopened, synchronize ] + +permissions: + contents: read # for checkout + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Python 3 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: 'pip' # caching pip dependencies + - name: Install dependencies + run: pip install -r requirements.txt + - name: Run local-setup + run: | + git clone https://github.com/matter-labs/local-setup.git + pushd local-setup + docker-compose up -d + popd + - name: Wait for local-setup to be ready + run: python scripts/wait.py + - name: Prepare environment + run: echo "Prepare env" + - name: Run tests + run: python -m unittest discover -s tests \ No newline at end of file diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..8042a35 --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,74 @@ +name: Validate +on: + pull_request: + branch: main + types: [ opened, reopened, synchronize ] + +permissions: + contents: read # for checkout + +jobs: + lint: + name: Check code format + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Python 3 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: 'pip' # caching pip dependencies + - name: Install dependencies + run: pip install black + - name: Check code format + run: black --check zksync2 + commits: + name: Check commits + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "lts/*" + - name: Install dependencies + run: npm install -g @commitlint/cli @commitlint/config-conventional + - name: Configure + run: | + echo 'module.exports = {"extends": ["@commitlint/config-conventional"]}' > commitlint.config.js + - name: Validate + run: | + git fetch + npx commitlint \ + --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} \ + --to ${{ github.event.pull_request.head.sha }} \ + --verbose + commits-fork: + name: Check commits from forks + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "lts/*" + - name: Install dependencies + run: npm install -g @commitlint/cli @commitlint/config-conventional + - name: Configure + run: | + echo 'module.exports = {"extends": ["@commitlint/config-conventional"]}' > commitlint.config.js + - name: Validate + run: | + git fetch origin "+refs/pull/${{ github.event.pull_request.number }}/head:refs/pull/${{ github.event.pull_request.number }}/head" + git checkout "refs/pull/${{ github.event.pull_request.number }}/head" + npx commitlint \ + --from HEAD~${{ github.event.pull_request.commits }} \ + --to HEAD \ + --verbose \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 3beabe5..4e121e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ eip712_structs == 1.1.0 web3==6.0.0 -eth-tester \ No newline at end of file +eth-tester +black \ No newline at end of file