From 7b4a4a171beacce4faef14841180777296cb67c7 Mon Sep 17 00:00:00 2001 From: Samuel Allan Date: Wed, 18 Sep 2024 08:50:14 +0930 Subject: [PATCH] Remove unused/old files (#82) - we don't use Sonar any more - Makefile and rename.sh are also not really used; use tox.ini or snapcraft directly. - update check.yaml to follow our latest conventions - we don't really use pre-commit any more, or the tox dev-environment target --- .github/workflows/check.yaml | 90 ++++++++++++++++++++++++++++++------ .github/workflows/sonar.yaml | 17 ------- .pre-commit-config.yaml | 22 --------- Makefile | 64 ------------------------- README-SNAP.md | 2 +- rename.sh | 17 ------- sonar-project.properties | 8 ---- tox.ini | 13 ------ 8 files changed, 76 insertions(+), 157 deletions(-) delete mode 100644 .github/workflows/sonar.yaml delete mode 100644 .pre-commit-config.yaml delete mode 100644 Makefile delete mode 100755 rename.sh delete mode 100644 sonar-project.properties diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 1dfdd19..5951086 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -1,11 +1,11 @@ -name: Check workflow running linter, unit and functional tests +name: Tests on: workflow_call: workflow_dispatch: pull_request: types: [opened, synchronize, reopened] - branches: [master, main] + branches: [main] paths-ignore: - "**.md" - "**.rst" @@ -15,22 +15,82 @@ concurrency: cancel-in-progress: true jobs: - lint-unit: - uses: canonical/bootstack-actions/.github/workflows/lint-unit.yaml@v2 + lint: + name: Lint strategy: fail-fast: false matrix: python-version: ["3.8", "3.10"] - with: - python-version: ${{ matrix.python-version }} - tox-version: "<4" + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + # pin tox to the current major version to avoid + # workflows breaking all at once when a new major version is released. + python -m pip install 'tox<5' + + - name: Run linters + run: tox -e lint + + unit: + name: Unit + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.10"] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install 'tox<5' + + - name: Run unit tests + run: tox -e unit func: - uses: canonical/bootstack-actions/.github/workflows/func.yaml@v2 - needs: lint-unit - with: - command: make functional - juju-channel: "3.4/stable" - nested-containers: true - python-version: "3.10" - timeout-minutes: 60 + name: Functional tests + needs: + - lint + - unit + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.10"] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install 'tox<5' + + - name: Run functional tests + run: tox -e func diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml deleted file mode 100644 index e002bbb..0000000 --- a/.github/workflows/sonar.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# This is a template `sonar.yaml` file for snaps -# This file is managed by bootstack-charms-spec and should not be modified -# within individual snap repos. https://launchpad.net/bootstack-charms-spec - -name: SonarCloud -on: - workflow_run: - workflows: - - Check workflow running linter, unit and functional tests - types: [completed] - -jobs: - sonar: - uses: canonical/bootstack-actions/.github/workflows/sonar.yaml@main - secrets: inherit - with: - workflow-name: Check workflow running linter, unit and functional tests diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 769738b..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# This is a template `.pre-commit-config.yaml` file for snaps -# This file is managed by bootstack-charms-spec and should not be modified -# within individual snap repos. https://launchpad.net/bootstack-charms-spec - -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 - hooks: - - id: check-executables-have-shebangs - - id: check-merge-conflict - - id: end-of-file-fixer - - id: trailing-whitespace - - id: check-added-large-files - - id: check-json - - id: check-yaml - - repo: local - hooks: - - id: lint - name: lint - entry: make lint - language: system - types: [ python ] diff --git a/Makefile b/Makefile deleted file mode 100644 index 4c5de68..0000000 --- a/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -# This is a template `Makefile` file for snaps -# This file is managed by bootstack-charms-spec and should not be modified -# within individual snap repos. https://launchpad.net/bootstack-charms-spec - -PYTHON := /usr/bin/python3 - -PROJECTPATH=$(dir $(realpath ${MAKEFILE_LIST})) -SNAP_NAME=$(shell cat ${PROJECTPATH}/snap/snapcraft.yaml | grep -E '^name:' | awk '{print $$2}') -SNAP_FILE=${PROJECTPATH}/${SNAP_NAME}.snap - -help: - @echo "This project supports the following targets" - @echo "" - @echo " make help - show this text" - @echo " make clean - remove unneeded files" - @echo " make dev-environment - setup the development environment" - @echo " make build - build the snap" - @echo " make lint - run lint checkers" - @echo " make reformat - run lint tools to auto format code" - @echo " make unittests - run the tests defined in the unittest subdirectory" - @echo " make functional - run the tests defined in the functional subdirectory" - @echo " make test - run lint, proof, unittests and functional targets" - @echo " make pre-commit - run pre-commit checks on all the files" - @echo "" - -lint: - @echo "Running lint checks" - @tox -e lint - -unittests: - @echo "Running unit tests" - @tox -e unit -- ${UNIT_ARGS} - -test: lint unittests functional - @echo "Tests completed for the snap." - -reformat: - @echo "Reformat files with black and isort" - @tox -e reformat - -build: - @echo "Building the snap" - @snapcraft --use-lxd - @bash -c ./rename.sh - -clean: - @echo "Cleaning snap" - @snapcraft clean --use-lxd - @echo "Cleaning existing snap builds" - @rm -rf ${SNAP_FILE} - -dev-environment: - @echo "Creating virtualenv and installing pre-commit" - @tox -r -e dev-environment - -functional: - @echo "Executing functional tests" - @tox -e func -- ${FUNC_ARGS} - -pre-commit: - @tox -e pre-commit - -# The targets below don't depend on a file -.PHONY: help clean dev-environment build lint reformat unittests functional test pre-commit diff --git a/README-SNAP.md b/README-SNAP.md index 969988b..5fdb60f 100644 --- a/README-SNAP.md +++ b/README-SNAP.md @@ -23,7 +23,7 @@ choose either of the following two backends for snapcraft: To build the snap: ```shell -make build +snapcraft --use-lxd ``` To try the snap that was built, you can install it locally: diff --git a/rename.sh b/rename.sh deleted file mode 100755 index 6d645e1..0000000 --- a/rename.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# This is a template `rename.sh` file for snaps -# This file is managed by bootstack-charms-spec and should not be modified -# within individual snap repos. https://launchpad.net/bootstack-charms-spec - -snap=$(grep -E "^name:" snap/snapcraft.yaml | awk '{print $2}') -echo "renaming ${snap}_*.snap to ${snap}.snap" -echo -n "pwd: " -pwd -ls -al -echo "Removing previous snap if it exists" -if [[ -e "${snap}.snap" ]]; -then - rm "${snap}.snap" -fi -echo "Renaming snap here." -mv ${snap}_*.snap ${snap}.snap diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index 6a57aef..0000000 --- a/sonar-project.properties +++ /dev/null @@ -1,8 +0,0 @@ -sonar.projectKey = prometheus-hardware-exporter -sonar.organization = bootstack-devops -sonar.python.version = 3 -sonar.python.coverage.reportPaths = tests/unit/report/coverage.xml -sonar.sources = prometheus_hardware_exporter/ -sonar.tests = tests/ -sonar.test.inclusions = test/** -sonar.coverage.exclusions=tests/**, docs/**, contrib/**, snap/**, * diff --git a/tox.ini b/tox.ini index b9c94fa..66f2ac4 100644 --- a/tox.ini +++ b/tox.ini @@ -11,19 +11,6 @@ skip_missing_interpreters = True basepython = python3 setenv = PYTHONPATH={toxinidir} -[testenv:dev-environment] -deps = - pre-commit - {[testenv:lint]deps} - {[testenv:unit]deps} - {[testenv:func]deps} -commands = - pre-commit install - -[testenv:pre-commit] -deps = {[testenv:dev-environment]deps} # ensure that dev-environment is installed -commands = pre-commit run --all-files - [testenv:lint] commands = pflake8