main.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. name: Main
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. env:
  7. # Among other things, opts out of Turborepo telemetry. See https://consoledonottrack.com/.
  8. DO_NOT_TRACK: '1'
  9. NODE_VERSION: 20
  10. CODAMA_VERSION: 1.x
  11. SOLANA_VERSION: 2.1.9
  12. jobs:
  13. lint:
  14. name: Check styling
  15. runs-on: ubuntu-latest
  16. steps:
  17. - name: Git checkout
  18. uses: actions/checkout@v4
  19. - name: Setup pnpm
  20. uses: pnpm/action-setup@v3
  21. - name: Setup Node.js
  22. uses: actions/setup-node@v4
  23. with:
  24. node-version: ${{ env.NODE_VERSION }}
  25. cache: 'pnpm'
  26. - name: Install dependencies
  27. run: pnpm install --frozen-lockfile
  28. - name: Compile JS and types
  29. run: pnpm run build
  30. - name: Check linting
  31. run: pnpm run lint
  32. tests:
  33. name: Test
  34. runs-on: ubuntu-latest
  35. steps:
  36. - name: Git checkout
  37. uses: actions/checkout@v4
  38. - name: Install Solana
  39. uses: solana-program/actions/install-solana@v1
  40. with:
  41. version: ${{ env.SOLANA_VERSION }}
  42. - name: Install pnpm
  43. uses: pnpm/action-setup@v3
  44. - name: Setup Node.js ${{ env.NODE_VERSION }}
  45. uses: actions/setup-node@v4
  46. with:
  47. node-version: ${{ env.NODE_VERSION }}
  48. cache: 'pnpm'
  49. - name: Install dependencies
  50. run: pnpm install --frozen-lockfile
  51. - name: Build and run tests
  52. run: pnpm run test
  53. - name: Ensure working directory is clean
  54. run: |
  55. git status
  56. test -z "$(git status --porcelain)"
  57. release:
  58. name: Release
  59. runs-on: ubuntu-latest
  60. if: github.event_name == 'push'
  61. needs: [lint, tests]
  62. permissions:
  63. contents: write
  64. pull-requests: write
  65. outputs:
  66. published: ${{ steps.changesets.outputs.published }}
  67. steps:
  68. - name: Checkout Repo
  69. uses: actions/checkout@v4
  70. - name: Setup pnpm
  71. uses: pnpm/action-setup@v3
  72. - name: Setup Node.js
  73. uses: actions/setup-node@v4
  74. with:
  75. node-version: ${{ env.NODE_VERSION }}
  76. cache: 'pnpm'
  77. - name: Install Dependencies
  78. run: pnpm install --frozen-lockfile
  79. - name: Create Release Pull Request or Publish
  80. id: changesets
  81. uses: changesets/action@v1
  82. with:
  83. commit: '[${{ env.CODAMA_VERSION }}] Publish packages'
  84. title: '[${{ env.CODAMA_VERSION }}] Publish packages'
  85. publish: pnpm publish-packages
  86. env:
  87. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  88. NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
  89. dependabot:
  90. runs-on: ubuntu-latest
  91. if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'codama-idl/codama'
  92. needs: [lint, tests]
  93. permissions:
  94. contents: write
  95. pull-requests: write
  96. steps:
  97. - name: Auto-approve the PR
  98. run: gh pr review --approve "$PR_URL"
  99. env:
  100. PR_URL: ${{ github.event.pull_request.html_url }}
  101. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  102. - name: Enable auto-merge
  103. run: gh pr merge --auto --squash "$PR_URL"
  104. env:
  105. PR_URL: ${{ github.event.pull_request.html_url }}
  106. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}