From 50222a1a702ab7b3f0a13668616bcbbd2297d2f0 Mon Sep 17 00:00:00 2001 From: Gil Barbara Date: Sun, 4 Feb 2024 21:38:53 -0300 Subject: [PATCH] Update CI/CD tools --- .codeclimate.yml | 32 -------------- .github/workflows/main.yml | 87 ++++++++++++++++++++++++++++++++++++++ .github/workflows/push.yml | 13 ------ .travis.yml | 20 --------- sonar-project.properties | 6 +++ 5 files changed, 93 insertions(+), 65 deletions(-) delete mode 100644 .codeclimate.yml create mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/push.yml delete mode 100644 .travis.yml create mode 100644 sonar-project.properties diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index ea472c5..0000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: '2' -checks: - argument-count: - config: - threshold: 4 - complex-logic: - config: - threshold: 4 - file-lines: - config: - threshold: 500 - identical-code: - config: - threshold: 50 - method-complexity: - config: - threshold: 20 - method-count: - config: - threshold: 20 - method-lines: - config: - threshold: 50 - similar-code: - config: - threshold: 100 -exclude_patterns: - - coverage/**/* - - dist/**/* - - cypress/**/* - - node_modules/**/* - - test/**/* diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..785232a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,87 @@ +name: CI + +on: + push: + branches: + - main + tags: + - 'v*' + pull_request: + branches: ['*'] + + workflow_dispatch: + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + main: + name: Validate and Deploy + runs-on: ubuntu-latest + + env: + CI: true + + steps: + - name: Setup timezone + uses: zcong1993/setup-timezone@master + with: + timezone: America/Sao_Paulo + + - name: Setup repo + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org' + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install Packages + run: | + pnpm install + pnpx cypress install + timeout-minutes: 3 + + - name: Validate and Build + run: pnpm run validate + timeout-minutes: 3 + + - name: E2E Tests + uses: cypress-io/github-action@v6 + with: + build: pnpm run build + start: pnpm start + wait-on: 'pnpx wait-on --timeout 60000 http://localhost:3000' + record: true + env: + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: SonarCloud Scan + if: "!startsWith(github.ref, 'refs/tags/')" + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml deleted file mode 100644 index 4619c66..0000000 --- a/.github/workflows/push.yml +++ /dev/null @@ -1,13 +0,0 @@ -on: push -name: packtracker.io -jobs: - report: - name: report webpack stats - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: report webpack stats - uses: packtracker/report@2.2.7 - env: - PT_PROJECT_TOKEN: ${{ secrets.PT_PROJECT_TOKEN }} - WEBPACK_CONFIG_PATH: ./config/webpack.config.js diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3b42fc2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: node_js -node_js: - - '14' -cache: - directories: - - 'node_modules' -before_script: - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - - chmod +x ./cc-test-reporter - - ./cc-test-reporter before-build -script: - - npm run validate -after_script: - - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT -addons: - apt: - packages: - - libgconf-2-4 -services: - - xvfb diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..2c21df2 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,6 @@ +sonar.projectKey=gilbarbara_react-redux-saga-boilerplate +sonar.organization=gilbarbara-github +sonar.source=./src +sonar.javascript.lcov.reportPaths=./coverage/lcov.info +sonar.exclusions=**/test/**/*.*,**/tools/**/*.* +sonar.coverage.exclusions=**/test/**/*.*,**/tools/**/*.*