Browse Source

Add main workflow

Loris Leiva 1 năm trước cách đây
mục cha
commit
56b0d2cf01
3 tập tin đã thay đổi với 75 bổ sung2 xóa
  1. 71 0
      .github/workflows/main.yml
  2. 2 1
      CONTRIBUTING.md
  3. 2 1
      package.json

+ 71 - 0
.github/workflows/main.yml

@@ -0,0 +1,71 @@
+name: Main
+
+on:
+  push:
+    branches: [main]
+  pull_request:
+    branches: [main]
+
+jobs:
+  lint:
+    name: Check styling
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: pnpm/action-setup@v2
+      - uses: actions/setup-node@v3
+        with:
+          node-version: 18
+          cache: "pnpm"
+      - name: Install dependencies
+        run: pnpm install --frozen-lockfile
+      - name: Check linting
+        run: pnpm run lint
+
+  tests:
+    name: Test
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        solana: ["1.17", "1.18"]
+
+    steps:
+      - uses: actions/checkout@v3
+      - uses: pnpm/action-setup@v2
+      - uses: actions/setup-node@v3
+        with:
+          node-version: 18
+          cache: "pnpm"
+      - uses: metaplex-foundation/actions/install-solana@v1
+        with:
+          version: ${{ matrix.solana }}
+      - name: Install dependencies
+        run: pnpm install --frozen-lockfile
+      - name: Build and run tests
+        run: pnpm test
+
+  release:
+    name: Release
+    runs-on: ubuntu-latest
+    if: github.event_name == 'push'
+    needs: [lint, tests]
+    outputs:
+      published: ${{ steps.changesets.outputs.published }}
+    steps:
+      - uses: actions/checkout@v3
+      - uses: pnpm/action-setup@v2
+      - uses: actions/setup-node@v3
+        with:
+          node-version: 18
+          cache: "pnpm"
+      - name: Install Dependencies
+        run: pnpm install --frozen-lockfile
+      - name: Create Release Pull Request or Publish
+        id: changesets
+        uses: changesets/action@v1
+        with:
+          commit: "Release packages"
+          title: "Release packages"
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

+ 2 - 1
CONTRIBUTING.md

@@ -26,7 +26,8 @@ The following scripts are available:
 pnpm build      # Build the `create-solana-program` package.
 pnpm snapshot   # Update the `projects` directory with the latest pre-defined templates.
 pnpm test       # Runs a snapshot and executes tests against each generated project.
-pnpm format     # Format the code using Prettier.
+pnpm lint       # Check the code using Prettier.
+pnpm lint:fix   # Format the code using Prettier.
 ```
 
 Additionally, a `prepublishOnly` script — that executes before every `pnpm publish` command — exists to update the snapshots and commit their changes to the relevant submodules. This allows us to have various template repositories that are always up-to-date with the latest changes of the `create-solana-program` package.

+ 2 - 1
package.json

@@ -16,7 +16,8 @@
   },
   "scripts": {
     "build": "./scripts/build.mjs",
-    "format": "prettier --write .",
+    "lint": "prettier -c .",
+    "lint:fix": "prettier --write .",
     "prepublishOnly": "./scripts/prepublish.mjs",
     "snapshot": "pnpm build && ./scripts/snapshot.mjs",
     "test": "pnpm snapshot --test"