diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..109c26d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,79 @@ +name: build and test pull-request + +on: + pull_request: + branches: + - main + workflow_dispatch: + # Allow workflow to be triggered manually. + +jobs: + detect-secrets: + name: detect-secrets + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Install detect-secrets + run: | + pip install --upgrade "git+https://github.com/ibm/detect-secrets.git@master#egg=detect-secrets" + + - name: Run detect-secrets + run: | + detect-secrets scan --update .secrets.baseline + detect-secrets -v audit --report --fail-on-unaudited --fail-on-live --fail-on-audited-real .secrets.baseline + + build: + name: Test on Node.js ${{ matrix.node-version }} + needs: detect-secrets + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20, 22, 24] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Display Node.js and npm versions + run: | + node --version + npm --version + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Run unit tests + run: npm run test-unit + + - name: Run linter + run: npm run lint + + - name: Check packages + run: npm run check-packages + + # - name: Upload coverage to Codecov + # if: matrix.node-version == 22 + # uses: codecov/codecov-action@v4 + # with: + # files: ./coverage/lcov.info + # flags: unittests + # name: codecov-umbrella + # fail_ci_if_error: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a87ea8a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,97 @@ +name: release + +on: + push: + branches: + - main + workflow_dispatch: + inputs: + dry_run: + description: 'Run semantic-release in dry-run mode' + required: false + type: boolean + default: true + +jobs: + build: + name: Build and Test (node v${{ matrix.node-version }}) + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20, 22, 24] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Display Node.js and npm versions + run: | + node --version + npm --version + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Run unit tests + run: npm run test-unit + + - name: Run linter + run: npm run lint + + - name: Check packages + run: npm run check-packages + + release: + name: Semantic Release + runs-on: ubuntu-latest + needs: build + permissions: + contents: write + issues: write + pull-requests: write + id-token: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Setup Node.js 22 + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Semantic Release (Dry Run) + if: github.event_name == 'workflow_dispatch' && inputs.dry_run + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release --dry-run + + - name: Semantic Release + if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.dry_run) + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release diff --git a/.travis.yml b/.travis.yml index 9d43a0a..ea9aad6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,2 @@ -dist: focal - -language: node_js - -node_js: -- 20 -- 22 - -before_install: -- node --version -- npm --version - -script: -- npm run build -- npm run test-unit-travis || travis_terminate 1 -- npm run lint -- npm run check-packages - -deploy: -- provider: script - skip_cleanup: true - script: npx semantic-release - on: - node: 22 - branch: main +# CI/CD has been migrated to GitHub Actions. +# See .github/workflows/ci.yml and .github/workflows/release.yml diff --git a/package.json b/package.json index 4ddda37..ab0b5e8 100644 --- a/package.json +++ b/package.json @@ -25,11 +25,10 @@ "postversion": "publisher --no-checks --dry-run", "semVerDryRun": "npx semantic-release -d", "test": "npm run build && npm run lint && jest test/", - "test-unit": "npm run build && jest test/unit/", + "test-unit": "npm run build && jest --runInBand test/unit/", "test-integration": "npm run build && jest test/integration", "test-examples": "npm run build && jest examples/", "test-travis": "jest --runInBand --testNamePattern='^((?!@slow).)*$' test/", - "test-unit-travis": "jest --runInBand test/unit/", "test-integration-travis": "jest --runInBand --no-colors --testNamePattern='^((?!@slow).)*$' --json test/integration > test-output.log" }, "license": "Apache-2.0",