From 8e7bcf8173cce312b2dc6e0e0c8533a17aa1d0cd Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Mon, 13 Jun 2022 08:41:04 +0100 Subject: [PATCH] Replace tox with taskfile as build tool (#311) --- .config/dictionary.txt | 4 +- .github/workflows/{npm.yml => task.yml} | 25 ++++---- .gitignore | 1 + Taskfile.yml | 79 +++++++++++++++++++++++++ package.json | 5 +- tox.ini | 30 ---------- 6 files changed, 96 insertions(+), 48 deletions(-) rename .github/workflows/{npm.yml => task.yml} (82%) create mode 100644 Taskfile.yml delete mode 100644 tox.ini diff --git a/.config/dictionary.txt b/.config/dictionary.txt index 74792e88..0e1769fb 100644 --- a/.config/dictionary.txt +++ b/.config/dictionary.txt @@ -2,16 +2,18 @@ DISTRO Devuan FQRN Junos -NXOS Mageia +NXOS SLES TMOS +Taskfile aci ansiblelint bigcrypt bindep bsdi cliconf +cmds codespell cpus dbservers diff --git a/.github/workflows/npm.yml b/.github/workflows/task.yml similarity index 82% rename from .github/workflows/npm.yml rename to .github/workflows/task.yml index ddf13a79..4d54dac2 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/task.yml @@ -1,4 +1,4 @@ -name: npm +name: task on: create: # is used for publishing to PyPI and TestPyPI @@ -19,17 +19,17 @@ on: # - cron: 2 18 * * 5 jobs: - npm: + task: runs-on: ubuntu-latest - name: ${{ matrix.npm_target }} + name: ${{ matrix.task_name }} strategy: matrix: node-version: [16.x] - npm_target: + task_name: - test - lint steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 # https://github.com/actions/cache - uses: actions/cache@v2 @@ -49,20 +49,19 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: Install test deps - run: | - npm ci - python3 -m pip install --upgrade pre-commit - - - run: npm ci + - name: Install Task + uses: arduino/setup-task@v1 + with: + version: 3.x + repo-token: ${{ secrets.GITHUB_TOKEN }} - - run: npm run ${{ matrix.npm_target }} + - run: task ${{ matrix.task_name }} check: # This job does nothing and is only used for the branch protection if: always() needs: - - npm + - task runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 7222ca3a..10c3f87e 100644 --- a/.gitignore +++ b/.gitignore @@ -129,3 +129,4 @@ dmypy.json .pyre/ node_modules report.html +.task diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 00000000..f9b459d9 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,79 @@ +# see https://taskfile.dev/#/ +version: "3" +output: group +vars: + VERSION: + sh: node -p "require('./package.json').version" +tasks: + default: + desc: Run most commands + deps: + - lint + - test + cmds: + - echo Passed all checks! + setup: + desc: Install dependencies + run: once # avoid duplicate runs as all task depend on this + cmds: + - npm ci + - pip3 install --user 'pip-tools>=6.6.2' pre-commit + # check that tools we need are installed + - npm --version + - pip-compile --version + - pre-commit --version + sources: + - Taskfile.yml + - package.json + - package-lock.json + deps: + desc: Update dependencies + deps: + - setup + cmds: + - pip-compile -q --no-header --no-annotate --output-file=requirements.txt + requirements.in + - npm run deps + lint: + desc: Lint the project + deps: + - setup + env: + PRE_COMMIT_COLOR: always + cmds: + - python3 -m pre_commit run -a + silent: true + sources: + - "*" + - "*.*" + - ".config" + - ".github" + - ".vscode" + - data + - f + - negative_test + - src + - test + test: + desc: Run all tests + deps: + - setup + cmds: + - npm run test + sources: + - f/ + - negative_test/ + - test/ + - src/ + - package.json + - package-lock.json + - Taskfile.yml + - tsconfig.json + interactive: true + pr: + desc: Opens a pull request using gh + deps: + - lint + cmds: + - gh pr create + interactive: true diff --git a/package.json b/package.json index a76e706e..108a40e5 100644 --- a/package.json +++ b/package.json @@ -8,12 +8,9 @@ "vscode-json-languageservice": "^5.0.0" }, "scripts": { - "ajv": "ajv", "compile": "tsc -p ./src", "deps": "npx npm-check-updates -u && npm install --ignore-scripts", - "lint": "pre-commit run -a", - "test": "mocha", - "postinstall": "pip install --user -r requirements.txt" + "test": "mocha" }, "devDependencies": { "@types/chai": "^4.3.1", diff --git a/tox.ini b/tox.ini deleted file mode 100644 index d7e6c255..00000000 --- a/tox.ini +++ /dev/null @@ -1,30 +0,0 @@ -[tox] -envlist = - lint - test -skipsdist = True - -[testenv] -allowlist_externals = - npm -description = Run tests -deps = - pre-commit -commands = - pre-commit run -a - -[testenv:test] -description = Run tests -deps = - -r requirements.txt -commands = - python src/rebuild.py - npm run test - -[testenv:deps] -description = Update project dependencies -deps = - pip-tools>=6.6.2 -commands = - pip-compile -q --no-header --no-annotate --output-file=requirements.txt requirements.in - npm run deps