diff --git a/.dagger/textlint-with-reviewdog.ts b/.dagger/textlint-with-reviewdog.ts new file mode 100644 index 0000000..25f1365 --- /dev/null +++ b/.dagger/textlint-with-reviewdog.ts @@ -0,0 +1,41 @@ +import Client, { connect } from '@dagger.io/dagger'; +// import { Secret } from '@dagger.io/dagger/dist/api/client.gen' + +// initialize Dagger client +connect(async (client: Client) => { + // read secret from host variable + // const secret: Secret = client.setSecret("gh-secret", process.env["GH_SECRET"]) + // const secret: Secret = client.setSecret("reviewdog-secret", process.env["REVIEWDOG_GITHUB_API_TOKEN"]) + + const source = client.host().directory('.', { exclude: ['node_modules/'] }); + const node = client.container().from('bitnami/node:18') + .withExec(['corepack', 'enable', 'pnpm']) + .withExec(['corepack', 'prepare', 'pnpm@latest', '--activate']) + .withExec(['apt-get', 'update']) + .withExec(['apt-get', 'install', 'git']) + .withExec(['curl', '-sfLO', 'https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh']) + .withExec(['sh', 'install.sh']); + + // textlint + const runner = node + .withMountedDirectory('/app', source) + .withExec(['pnpm', 'install']) + // .withSecretVariable('GITHUB_TOKEN', secret) + .withEnvVariable('REVIEWDOG_GITHUB_API_TOKEN', process.env["GITHUB_API_TOKEN"]) + .withEnvVariable('CI_REPO_OWNER', process.env["CI_REPO_OWNER"]) + .withEnvVariable('CI_REPO_NAME', process.env["CI_REPO_NAME"]) + .withEnvVariable('CI_COMMIT', process.env["CI_COMMIT"]) + // .withExec(['echo', process.env["GITHUB_API_TOKEN"]]) + // .withExec(['echo', process.env["github"]]) + // .withEnvVariable('REVIEWDOG_GITHUB_API_TOKEN', process.env["GITHUB_API_TOKEN"]) + // .withExec(['REVIEWDOG_GITHUB_API_TOKEN=' + process.env["REVIEWDOG_GITHUB_API_TOKEN"], './bin/reviewdog', '-conf=./.reviewdog.yml', '-runners=textlint', '-reporter=github-check', '-filter-mode=nofilter']); + .withExec(['./bin/reviewdog', '-conf=./.reviewdog.yml', '-runners=textlint', '-reporter=github-check', '-filter-mode=nofilter', '-tee']); + // .withExec(['./bin/reviewdog', '-conf=./.reviewdog.yml', '-runners=textlint', '-diff=/usr/bin/git diff main']); + + // execute + const textlintResult = await runner.stdout(); + + // print output + console.log(textlintResult); +}); + diff --git a/.github/workflows/linter-textlint-dagger.yml b/.github/workflows/linter-textlint-dagger.yml index c6a38a4..554384c 100644 --- a/.github/workflows/linter-textlint-dagger.yml +++ b/.github/workflows/linter-textlint-dagger.yml @@ -13,9 +13,25 @@ jobs: node-version: 18 - name: Run npm install run: npm install - - name: Reviewdog Install + - name: reviewdog Install run: curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b ./bin - name: Run textlint on Dagger env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./bin/reviewdog -conf=./.reviewdog.yml -runners=textlint_dagger -reporter=github-check -filter-mode=nofilter + textlint_with_reviewdog_on_dagger: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Run npm install + run: npm install + - name: Run textlint on Dagger + env: + GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CI_REPO_OWNER: ${{ github.repository_owner }} + CI_REPO_NAME: custom-rules-for-static-code-analysis + CI_COMMIT: ${{ github.sha }} + run: node --loader ts-node/esm ./.dagger/textlint-with-reviewdog.ts diff --git a/build.ts b/build.ts deleted file mode 100644 index a74e3ba..0000000 --- a/build.ts +++ /dev/null @@ -1,25 +0,0 @@ -import Client, { connect } from '@dagger.io/dagger'; - -// initialize Dagger client -connect(async (client: Client) => { - // get Node image - // get Node version - // const node = client.container().from('bitnami/node:18').withExec(['node', '-v']); - const source = client.host().directory('.', { exclude: ['node_modules/'] }); - const node = client.container().from('bitnami/node:18') - .withExec(['corepack', 'enable', 'pnpm']) - .withExec(['corepack', 'prepare', 'pnpm@latest', '--activate']); - - // textlint - const runner = client - .container({ id: node }) - .withMountedDirectory('/app', source) - .withExec(['pnpm', 'install']) - .withExec(['pnpm', 'run', 'textlint']); - - // execute - const textlintResult = await runner.stdout(); - - // print output - console.log(textlintResult); -}); diff --git a/package.json b/package.json index ffde691..89873a2 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "textlint": "textlint -f compact src/**/*.md || true", "stylelint": "stylelint -f github src/**/*.scss || true", "dagger:textlint": "node --loader ts-node/esm ./.dagger/textlint.ts", + "dagger:textlint:reviewdog": "node --loader ts-node/esm ./.dagger/textlint-with-reviewdog.ts", "dagger:eslint": "node --loader ts-node/esm ./.dagger/eslint.ts" }, "keywords": [ diff --git a/src/TextlintSample.md b/src/TextlintSample.md index 0ee96e4..aeed547 100644 --- a/src/TextlintSample.md +++ b/src/TextlintSample.md @@ -13,3 +13,22 @@ JTF 標準 〜かもしれない 予め + +github + +予め +JTF 標準 + +これは,見本となる例です. + +概ね + +〜する上(で) + +〜して頂く + +~することが可能である + +〜かもしれない + +予め