diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml new file mode 100644 index 0000000..b6acabc --- /dev/null +++ b/.github/workflows/check-dist.yml @@ -0,0 +1,58 @@ +name: Check dist/ + +on: + push: + branches: + - main + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' + workflow_dispatch: + +jobs: + check-dist: + name: Check dist/ + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .node-version + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Build dist/ + run: npm run build + + - name: Compare expected and actual dist/ directories + run: | + if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then + echo "Detected uncommitted changes after build. See status below:" + git diff --ignore-space-at-eol --text dist/ + exit 1 + fi + id: diff + + - name: Upload artifact + if: ${{ failure() && steps.diff.conclusion == 'failure' }} + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + + - name: Fail if dist/ is out of sync + if: ${{ failure() && steps.diff.conclusion == 'failure' }} + run: | + echo "::error::The dist/ directory is out of sync with the source code. Run 'npm run build' and commit the changes." + exit 1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..93597a0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: Continuous Integration + +on: + pull_request: + branches: + - main + push: + branches: + - main + +permissions: + contents: write + issues: write + pull-requests: write + +jobs: + test-action: + name: GitHub Actions Test + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .node-version + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test + + - name: Test Local Action + uses: ./ + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + small-threshold: 100 + medium-threshold: 300 + large-threshold: 600 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c08a3a9..19f8230 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,11 +24,15 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20' + node-version-file: .node-version + cache: npm - name: Install dependencies run: npm ci + - name: Build dist/ + run: npm run build + - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..209e3ef --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +20 diff --git a/package.json b/package.json index 1a9dcd7..60558d3 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,11 @@ "description": "GitHub Action to automatically label PRs based on size", "main": "index.js", "scripts": { - "build": "ncc build index.js -o dist", - "test": "echo \"Error: no test specified\" && exit 1", + "bundle": "npm run build", + "build": "ncc build index.js -o dist --license licenses.txt", + "package": "ncc build index.js -o dist --license licenses.txt", + "all": "npm run build", + "test": "echo \"No tests yet\"", "semantic-release": "semantic-release" }, "repository": {