diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml new file mode 100644 index 00000000..dd5ac610 --- /dev/null +++ b/.github/actions/setup-node/action.yml @@ -0,0 +1,17 @@ +name: "Setup Node environment" +description: "Setup Node.js environment" +inputs: + node-version: + description: Node.js version + default: "18.x" +runs: + using: "composite" + steps: + - uses: actions/setup-node@v1 + with: + node-version: ${{ inputs.node-version }} + cache: "pnpm" + - run: corepack enable + shell: bash + - run: pnpm install --frozen-lockfile + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9df6d7b..3324df6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,53 +1,67 @@ name: CI -on: [push] +on: + pull_request: + branches: + - "**" + push: + branches: + - main jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-node + - run: pnpm lint + - name: check code is up to date + run: git diff --exit-code + + format: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-node + - run: pnpm format + - name: check code is up to date + run: git diff --exit-code + test: name: Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - submodules: true - - uses: pnpm/action-setup@v2 - with: - version: 7 - - uses: actions/setup-node@v1 - with: - node-version: 18.x - cache: 'pnpm' - - uses: bufbuild/buf-setup-action@v1 - with: - github_token: ${{ github.token }} - - run: pnpm install --frozen-lockfile - - run: pnpm test - - name: Coveralls - uses: coverallsapp/github-action@v1.1.2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: packages/protoc-gen-nexus/coverage/lcov.info - base-path: packages/protoc-gen-nexus + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-node + - run: pnpm test + - name: check code is up to date + run: git diff --exit-code + - name: Coveralls + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: packages/protoc-gen-nexus/coverage/lcov.info + base-path: packages/protoc-gen-nexus test-e2e: name: E2E Test - Node.js v${{ matrix.node-version }} strategy: matrix: - node-version: [16, 18] + node-version: ["16.x", "18.x"] + fail-fast: false runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - submodules: true - - uses: pnpm/action-setup@v2 - with: - version: 7 - - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - cache: 'pnpm' - - uses: bufbuild/buf-setup-action@v1 - with: - github_token: ${{ github.token }} - - run: pnpm install --frozen-lockfile - - run: pnpm test:e2e + - uses: actions/checkout@v3 + with: + submodules: true + - uses: ./.github/actions/setup-node + with: + node-version: ${{ matrix.node-version }} + - uses: bufbuild/buf-setup-action@v1 + with: + github_token: ${{ github.token }} + - run: pnpm test:e2e + - name: check code is up to date + run: git diff --exit-code diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 0e9c8f17..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Lint - -on: [pull_request] - -jobs: - lint: - name: Lint and Format - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - submodules: true - - uses: pnpm/action-setup@v2 - with: - version: 7 - - uses: actions/setup-node@v1 - with: - node-version: 18.x - cache: 'pnpm' - - run: pnpm install --frozen-lockfile - - run: pnpm lint - - run: pnpm format - - name: check code is up to date - run: git diff --exit-code diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9b29cc13..169b18e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,21 +17,11 @@ jobs: contents: write pull-requests: write steps: - - name: Checkout Repo - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: true - - uses: pnpm/action-setup@v2 - with: - version: 7 - - uses: actions/setup-node@v2 - with: - node-version: 18.x - cache: 'pnpm' - - - name: Install Dependencies - run: pnpm install --frozen-lockfile + - uses: ./.github/actions/setup-node - name: Create Release Pull Request or Publish to npm id: changesets