From bdea0ff3cf9f307b99293edacce338636d7a7606 Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Mon, 22 Apr 2024 07:21:43 -0700 Subject: [PATCH] ci: update tests, add codecov coverage --- .github/workflows/tests.yaml | 253 ++++++++++++++++++++++++++++++++++ .github/workflows/verify.yaml | 31 ----- 2 files changed, 253 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/tests.yaml delete mode 100644 .github/workflows/verify.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 00000000..0a3fd45d --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,253 @@ +name: "๐Ÿงฐ Tests" +run-name: "๐Ÿงฐ Tests" + +on: + push: + branches: + - 'main' + - 'master' + - 'develop' + - 'development' + - '!all-contributors/**' + + pull_request: + workflow_dispatch: + +jobs: + + # --------------------------------------------------------------------------------------- + # JOB > INITIALIZE + # --------------------------------------------------------------------------------------- + + job-initialize-run: + name: >- + ๐Ÿ’ก Initialize + runs-on: ubuntu-latest + outputs: + package_version: ${{ steps.task_initialize_package_getversion.outputs.PACKAGE_VERSION }} + permissions: + contents: write + packages: write + steps: + + - name: "โœ… Start" + id: task_initialize_start + run: | + echo "Starting build" + + # --------------------------------------------------------------------------------------- + # Job > Lint > Checkout + # --------------------------------------------------------------------------------------- + + - name: "โ˜‘๏ธ Checkout" + id: task_lint_run_checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # --------------------------------------------------------------------------------------- + # Job > Lint > Setup Node + # --------------------------------------------------------------------------------------- + + - name: "โš™๏ธ Setup Node" + id: task_lint_node_setup + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + + # --------------------------------------------------------------------------------------- + # Job > Lint > NPM Install + # --------------------------------------------------------------------------------------- + + - name: "๐Ÿ•› NPM โ€บ Clean Install" + id: task_lint_npm_install + run: | + npm ci + + # --------------------------------------------------------------------------------------- + # Get version from package.json VERSION value + # --------------------------------------------------------------------------------------- + + - name: "๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ Get Package Version" + id: task_initialize_package_getversion + run: | + VER=$(cat package.json | jq -r '.version') + echo "PACKAGE_VERSION=$VER" >> $GITHUB_OUTPUT + + - name: "๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ Found KeeWeb v${{ steps.task_initialize_package_getversion.outputs.PACKAGE_VERSION }}" + id: task_initialize_package_getversion_debug + run: | + echo Found KeeWeb ${{ steps.task_initialize_package_getversion.outputs.PACKAGE_VERSION }} + + # --------------------------------------------------------------------------------------- + # generate guid and uuid + # --------------------------------------------------------------------------------------- + + - name: "๐Ÿชช .ENV โ€บ Generate" + id: task_initialize_npm_env_generate + run: | + npm run keeweb:generate + + # --------------------------------------------------------------------------------------- + # assign guid and uuid to env variable + # --------------------------------------------------------------------------------------- + + - name: "๐Ÿชช .ENV โ€บ Get" + id: task_initialize_dotenv_get + uses: falti/dotenv-action@v1 + + # --------------------------------------------------------------------------------------- + # read back guid and uuid + # --------------------------------------------------------------------------------------- + + - name: "๐Ÿชช .ENV โ€บ Read" + id: task_dotenv_debug_print + run: | + echo "VER: ${{ steps.task_initialize_dotenv_get.outputs.VERSION }}" + echo "GUID: ${{ steps.task_initialize_dotenv_get.outputs.GUID }}" + echo "UUID: ${{ steps.task_initialize_dotenv_get.outputs.UUID }}" + + # --------------------------------------------------------------------------------------- + # JOB > LINT + # --------------------------------------------------------------------------------------- + + job-lint-run: + name: >- + ๐Ÿ“š Lint + runs-on: ubuntu-latest + needs: [ job-initialize-run ] + env: + PACKAGE_VERSION: ${{ needs.job-initialize-run.outputs.package_version }} + steps: + + # --------------------------------------------------------------------------------------- + # Job > Lint > Checkout + # --------------------------------------------------------------------------------------- + + - name: "โ˜‘๏ธ Checkout" + id: task_lint_run_checkout + uses: actions/checkout@v4 + + # --------------------------------------------------------------------------------------- + # Job > Lint > Setup Node + # --------------------------------------------------------------------------------------- + + - name: "โš™๏ธ Setup Node" + id: task_lint_node_setup + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + + # --------------------------------------------------------------------------------------- + # Job > Lint > NPM Install + # --------------------------------------------------------------------------------------- + + - name: "๐Ÿ•› NPM โ€บ Clean Install" + id: task_lint_npm_install + run: | + npm ci + + # --------------------------------------------------------------------------------------- + # Job > Lint > Run + # --------------------------------------------------------------------------------------- + + - name: "๐Ÿ•ž NPM โ€บ Lint" + id: task_lint_npm_lint + run: | + npm run lint + + # --------------------------------------------------------------------------------------- + # Job > Lint > Coverage + # --------------------------------------------------------------------------------------- + + - name: "๐Ÿ•˜ NPM โ€บ Coverage" + id: task_lint_npm_coverage + run: | + npm run coverage + + # --------------------------------------------------------------------------------------- + # Job > Tests > Upload Coverage to Codecov + # --------------------------------------------------------------------------------------- + + - name: "๐Ÿ“ Upload Coverage Reports โ€บ Codecov" + id: task_lint_codecov_upload + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: Aetherinox/keeweb + + # --------------------------------------------------------------------------------------- + # JOB > TESTS + # --------------------------------------------------------------------------------------- + + job-tests-run: + name: >- + ๐Ÿงช Tests + runs-on: ubuntu-latest + needs: [ job-initialize-run ] + env: + PACKAGE_VERSION: ${{ needs.job-initialize-run.outputs.package_version }} + steps: + + # --------------------------------------------------------------------------------------- + # Job > Tests > Fix Line Endings + # --------------------------------------------------------------------------------------- + + - name: "๐Ÿ›’ Fix Git Checkout Line Endings" + id: task_tests_git-fixlines + run: | + git config --global core.autocrlf input + + # --------------------------------------------------------------------------------------- + # Job > Tests > Checkout + # --------------------------------------------------------------------------------------- + + - name: "โ˜‘๏ธ Checkout" + id: task_tests_run_checkout + uses: actions/checkout@v4 + + # --------------------------------------------------------------------------------------- + # Job > Tests > Setup Node + # --------------------------------------------------------------------------------------- + + - name: "โš™๏ธ Setup Node" + id: task_tests_node_setup + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + + # --------------------------------------------------------------------------------------- + # Job > Tests > NPM Install + # --------------------------------------------------------------------------------------- + + - name: "๐Ÿ•› NPM โ€บ Clean Install" + id: task_tests_npm_install + run: | + npm ci + + # --------------------------------------------------------------------------------------- + # Job > Tests > Run Lint + # --------------------------------------------------------------------------------------- + + - name: "๐Ÿ•˜ NPM โ€บ Lint" + id: task_tests_npm_lint + run: | + npm run test + + # --------------------------------------------------------------------------------------- + # JOB > COMPLETE + # --------------------------------------------------------------------------------------- + + job-complete-run: + name: >- + โœ… Complete + runs-on: ubuntu-latest + needs: [ job-initialize-run, job-lint-run, job-tests-run ] + env: + PACKAGE_VERSION: ${{ needs.job-initialize-run.outputs.package_version }} + steps: + + - name: "โ˜‘๏ธ Tests Complete" + id: task_tests_complete + run: | + echo 'Linting and tests successfully completed for KeeWeb ${{ env.PACKAGE_VERSION }}' diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml deleted file mode 100644 index da0886eb..00000000 --- a/.github/workflows/verify.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: Verify -on: - push: - pull_request: - workflow_dispatch: - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache: 'npm' - - name: Install npm modules - run: npm ci - - name: Lint - run: npm run lint - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache: 'npm' - - name: Install npm modules - run: npm ci - - name: Test - run: npm test