diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..97222c5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,96 @@ +name: Bug Report 🪲 +description: Create a bug report to help us improve +title: '[Bug]: ' +labels: ['Bug Report', 'Needs Triage'] +body: + - type: markdown + attributes: + value: | + # Please follow these steps first: + - type: markdown + attributes: + value: | + ## Make a minimal reproduction + To file the report, you will need to provide a minimal (but complete) example and simple/clear steps on how to reproduce the bug. + + The simpler you can make it, the more likely we are to successfully verify and fix the bug. + - type: markdown + attributes: + value: | + :bangbang:   Bug reports without a minimal reproduction will be rejected. :bangbang: + + --- + - type: input + id: version + attributes: + label: Version + description: | + The version of library you are using. + Is it the latest? Test and see if the bug has already been fixed. + placeholder: ex. 0.3.0 + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: Steps to reproduce + description: Please provide a minimal reproduction and describe accurately how we can reproduce/verify the bug. + placeholder: | + Example steps (replace with your own): + 1. Clone my repo at https://github.com//example + 2. yarn install + 3. yarn test + 4. You should see the error come up + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected behavior + description: A description of what you expect to happen. + placeholder: I expect to see X or Y + validations: + required: true + - type: textarea + id: what-happened + attributes: + label: Actual behavior + description: A clear and concise description of the unexpected behavior. + placeholder: A bug happened! + validations: + required: true + - type: textarea + id: context + attributes: + label: Additional context + description: Anything else that might be relevant + validations: + required: false + - type: textarea + id: envinfo + attributes: + label: Environment + description: | + Please paste the output of running `npx envinfo --system --binaries --npmPackages`. + This will be automatically formatted as a code block, so no need for backticks. + placeholder: | + System: + OS: Linux 5.10 Debian GNU/Linux 9 (stretch) + CPU: (8) arm64 + Binaries: + Node: 14.17.0 - /usr/local/bin/node + Yarn: 1.22.5 - /usr/local/bin/yarn + npm: 6.14.13 - /usr/local/bin/npm + npmPackages: + @cuaklabs/ajstt: 0.1.0 => 0.1.0 + render: Shell + validations: + required: true + - type: markdown + attributes: + value: | + --- + + ## Aknowledgements + + This issue template is highly inspired by the [jest](https://github.com/facebook/jest/blob/main/.github/ISSUE_TEMPLATE/bug.yml) one, so I would like to thank the jest team for providing it ❤️. diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..2cd48aa --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,158 @@ +name: build +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +on: + pull_request: + types: + - closed + - opened + - reopened + - synchronize +jobs: + build: + name: Build + runs-on: ubuntu-latest + outputs: + affectedPackages: ${{ steps.get-affected-packages.outputs.packages }} + if: "!(github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == false)" + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install + with: + version: 8 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: pnpm-store-${{ hashFiles('**/package.json') }} + restore-keys: | + pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Get affected packages + id: get-affected-packages + run: echo "packages=$(pnpm exec script-get-affected-projects test origin/${{github.base_ref}})" >> $GITHUB_OUTPUT + + - name: Compile source files + run: pnpm run build + + - name: Lint affected source files + run: pnpm run lint --filter=[origin/${{github.base_ref}}] + + - name: Get current git commit hash + id: get-git-commit-hash + run: | + echo "gitCommitHash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + id: ts-build-cache + with: + path: | + ./packages + key: ts-build-${{ steps.get-git-commit-hash.outputs.gitCommitHash }} + restore-keys: | + ts-build-${{ steps.get-git-commit-hash.outputs.gitCommitHash }} + + test-package: + name: Test package + needs: build + runs-on: ubuntu-latest + if: ${{ needs.build.outputs.affectedPackages != '[]' }} + strategy: + matrix: + package: ${{fromJSON(needs.build.outputs.affectedPackages)}} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install + with: + version: 8 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: pnpm-store-${{ hashFiles('**/package.json') }} + restore-keys: | + pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Get current git commit hash + id: get-git-commit-hash + run: | + echo "gitCommitHash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + id: ts-build-cache + with: + path: | + ./packages + key: ts-build-${{ steps.get-git-commit-hash.outputs.gitCommitHash }} + restore-keys: | + ts-build-${{ steps.get-git-commit-hash.outputs.gitCommitHash }} + + - name: Build on cache miss + run: pnpm run build --filter ${{ matrix.package }} + if: ${{ !steps.ts-build-cache.outputs.cache-hit }} + + - name: Launch Unit Tests + run: pnpm run test:unit --filter ${{ matrix.package }} --only + + - name: Launch Integration Tests + run: pnpm run test:integration --filter ${{ matrix.package }} --only + + - name: Start SSH session on failure + if: ${{ failure() && contains(github.event.head_commit.message, '[ci-open-ssh]') }} + uses: luchihoratiu/debug-via-ssh@main + with: + NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }} + SSH_PASS: ${{ secrets.SSH_PASS }} + + - name: Don't kill instace on failure + if: ${{ failure() && contains(github.event.head_commit.message, '[ci-open-ssh]') }} + run: sleep 1h + + done: + name: Done + needs: + - test-package + runs-on: ubuntu-latest + steps: + - run: 'echo "Done!"' diff --git a/package.json b/package.json index 7a16e61..c114287 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,9 @@ "format": "turbo run format", "lint": "turbo run lint", "prepare": "husky install", - "test:integration": "turbo test:integration", "test": "turbo run test", "test:coverage": "turbo run test:coverage", + "test:integration": "turbo run test:integration", "test:uncommitted": "turbo run test:uncommitted --filter [HEAD]", "test:unit": "turbo run test:unit" },