|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + name: ${{ matrix.config.kind }} ${{ matrix.config.os }} |
| 8 | + runs-on: ${{ matrix.config.os }} |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + config: |
| 12 | + - os: ubuntu-latest |
| 13 | + kind: test_release |
| 14 | + - os: ubuntu-latest |
| 15 | + kind: test_debug |
| 16 | + |
| 17 | + env: |
| 18 | + CARGO_INCREMENTAL: 0 |
| 19 | + RUST_BACKTRACE: full |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v3 |
| 23 | + - uses: dsherret/rust-toolchain-file@v1 |
| 24 | + - name: Install wasm32 target |
| 25 | + if: matrix.config.kind == 'test_release' |
| 26 | + run: rustup target add wasm32-unknown-unknown |
| 27 | + |
| 28 | + - uses: Swatinem/rust-cache@v2 |
| 29 | + with: |
| 30 | + save-if: ${{ github.ref == 'refs/heads/main' }} |
| 31 | + |
| 32 | + - name: Build debug |
| 33 | + if: matrix.config.kind == 'test_debug' |
| 34 | + run: cargo build |
| 35 | + - name: Build release |
| 36 | + if: matrix.config.kind == 'test_release' |
| 37 | + run: cargo build --target wasm32-unknown-unknown --features wasm --release |
| 38 | + |
| 39 | + - name: Test debug |
| 40 | + if: matrix.config.kind == 'test_debug' |
| 41 | + run: cargo test |
| 42 | + - name: Test release |
| 43 | + if: matrix.config.kind == 'test_release' |
| 44 | + run: cargo test --release |
| 45 | + |
| 46 | + - name: Get tag version |
| 47 | + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 48 | + id: get_tag_version |
| 49 | + run: echo ::set-output name=TAG_VERSION::${GITHUB_REF/refs\/tags\//} |
| 50 | + |
| 51 | + # todo: waiting on https://github.com/dprint/js-formatter/issues/2 |
| 52 | + # NPM |
| 53 | + # - uses: actions/setup-node@v2 |
| 54 | + # if: matrix.config.kind == 'test_release' |
| 55 | + # with: |
| 56 | + # node-version: '18.x' |
| 57 | + # registry-url: 'https://registry.npmjs.org' |
| 58 | + |
| 59 | + # - name: Setup and test npm deployment |
| 60 | + # if: matrix.config.kind == 'test_release' |
| 61 | + # run: | |
| 62 | + # cd deployment/npm |
| 63 | + # npm install |
| 64 | + # node setup.js ${{ steps.get_tag_version.outputs.TAG_VERSION }} |
| 65 | + # npm run test |
| 66 | + |
| 67 | + # - name: npm publish |
| 68 | + # if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 69 | + # env: |
| 70 | + # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 71 | + # run: | |
| 72 | + # cd deployment/npm |
| 73 | + # npm publish --access public |
| 74 | + # git reset --hard |
| 75 | + |
| 76 | + # CARGO PUBLISH |
| 77 | + - name: Cargo login |
| 78 | + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 79 | + run: cargo login ${{ secrets.CRATES_TOKEN }} |
| 80 | + |
| 81 | + - name: Cargo publish |
| 82 | + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 83 | + run: cargo publish |
| 84 | + |
| 85 | + # GITHUB RELEASE |
| 86 | + - name: Pre-release |
| 87 | + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 88 | + run: | |
| 89 | + # update config schema to have version |
| 90 | + sed -i 's/jupyter\/0.0.0/jupyter\/${{ steps.get_tag_version.outputs.TAG_VERSION }}/' deployment/schema.json |
| 91 | + # rename the wasm file |
| 92 | + (cd target/wasm32-unknown-unknown/release/ && mv dprint_plugin_jupyter.wasm plugin.wasm) |
| 93 | + - name: Release |
| 94 | + uses: softprops/action-gh-release@v1 |
| 95 | + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 96 | + env: |
| 97 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + with: |
| 99 | + files: | |
| 100 | + target/wasm32-unknown-unknown/release/plugin.wasm |
| 101 | + deployment/schema.json |
| 102 | + body: | |
| 103 | + ## Install |
| 104 | +
|
| 105 | + [Install](https://dprint.dev/install/) and [setup](https://dprint.dev/setup/) dprint. |
| 106 | +
|
| 107 | + Then in your project's directory with a dprint.json file, run: |
| 108 | +
|
| 109 | + ```shellsession |
| 110 | + dprint config add jupyter |
| 111 | + ``` |
| 112 | +
|
| 113 | + Then add some additional formatting plugins to format the code blocks with. For example: |
| 114 | +
|
| 115 | + ```shellsession |
| 116 | + dprint config add typescript |
| 117 | + dprint config add markdown |
| 118 | + dprint config add ruff |
| 119 | + ``` |
| 120 | +
|
| 121 | + # ## JS Formatting API |
| 122 | + |
| 123 | + # * [JS Formatter](https://github.com/dprint/js-formatter) - Browser/Deno and Node |
| 124 | + # * [npm package](https://www.npmjs.com/package/@dprint/jupyter) |
| 125 | + draft: false |
0 commit comments