From 0b63fa0de05c519c6471bf1f72e4a4d25869ba09 Mon Sep 17 00:00:00 2001 From: Maciej Pyrc Date: Fri, 18 Oct 2024 19:31:20 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 46 -------------- .github/workflows/tests.yml | 41 ------------ .github/workflows/workflow.yml | 112 +++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 87 deletions(-) delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/tests.yml create mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 6d9b386..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Release packages - -on: - push: - branches: - - main - - beta - - alpha - -defaults: - run: - shell: sh - -jobs: - release: - name: Release - runs-on: ubuntu-latest - steps: - - name: Wait on tests - uses: lewagon/wait-on-check-action@v1.1.2 - with: - ref: ${{ github.ref }} - check-name: "Run tests" - repo-token: ${{ secrets.GITHUB_TOKEN }} - wait-interval: 10 - - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up Node - uses: actions/setup-node@v3 - with: - node-version: "16" - cache: "yarn" - - - name: Install packages - run: yarn install --frozen-lockfile - - - name: Build - run: yarn build - - - name: Publish - run: yarn release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 80b3a79..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Tests - -on: push - -jobs: - tests: - name: Run tests - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: "16" - cache: "yarn" - - - name: Install packages - run: yarn install --frozen-lockfile - - - name: Build - run: yarn build - - - name: Lint - run: yarn lint - - - name: Clear Jest - run: yarn jest --clearCache - - - name: Test - run: yarn test --coverage - - # - name: Send Report - # uses: paambaati/codeclimate-action@v3.0.0 - # env: - # CC_TEST_REPORTER_ID: c206a2ed5aa86c7480a13634e91e440a27a98a5d134653f8ea9a7d5f987e68c3 - # with: - # coverageLocations: | - # ${{github.workspace}}/packages/core/coverage/lcov.info:lcov - # ${{github.workspace}}/packages/react/coverage/lcov.info:lcov diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..28e27fd --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,112 @@ +name: Workflow +on: push + +concurrency: + group: + "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || + github.ref }}" + cancel-in-progress: true + +defaults: + run: + shell: sh + +jobs: + prepare-environment: + runs-on: ubuntu-latest + name: Prepare environment + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: "18" + cache: "yarn" + cache-dependency-path: yarn.lock + env: + FORCE_COLOR: 0 + - name: Install node_modules on cache miss + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile + - name: Cache node_modules + if: steps.cache-node-modules.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + path: node_modules + key: yarn-${{ hashFiles('yarn.lock') }} + + tests: + name: Run tests + runs-on: ubuntu-latest + needs: prepare-environment + # Tests timeout after 40 minutes + timeout-minutes: 40 + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: "18" + cache: "yarn" + cache-dependency-path: yarn.lock + - name: Restore node_modules + uses: actions/cache/restore@v3 + id: cache-node-modules + with: + path: node_modules + key: yarn-${{ hashFiles('yarn.lock') }} + fail-on-cache-miss: false + - name: Install node_modules on cache miss + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile + - name: Build + run: yarn build + - name: Lint + run: yarn lint + - name: Clear Jest + run: yarn jest --clearCache + - name: Test + run: yarn test --coverage + # - name: Send Report + # uses: paambaati/codeclimate-action@v3.0.0 + # env: + # CC_TEST_REPORTER_ID: c206a2ed5aa86c7480a13634e91e440a27a98a5d134653f8ea9a7d5f987e68c3 + # with: + # coverageLocations: | + # ${{github.workspace}}/packages/core/coverage/lcov.info:lcov + # ${{github.workspace}}/packages/react/coverage/lcov.info:lcov + + release: + name: Release + if: ${{ github.ref == 'refs/heads/main' }} + runs-on: ubuntu-latest + needs: tests + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: "18" + cache: "yarn" + cache-dependency-path: yarn.lock + - name: Restore node_modules + uses: actions/cache/restore@v3 + id: cache-node-modules + with: + path: node_modules + key: yarn-${{ hashFiles('yarn.lock') }} + fail-on-cache-miss: false + - name: Install node_modules on cache miss + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile + - name: Build + run: yarn build + - name: Publish + run: yarn release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }}