Skip to content

Commit

Permalink
test: test node packages
Browse files Browse the repository at this point in the history
  • Loading branch information
charislam committed Dec 6, 2024
1 parent dda2a52 commit 7477321
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 0 deletions.
166 changes: 166 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,169 @@ jobs:
name: artifact-npm-binary-distributions
path: npm-binary-distributions/*/*.tgz
if-no-files-found: "error"

test-linux:
runs-on: ubuntu-latest
needs: [node, npm-distributions]
strategy:
fail-fast: false
matrix:
node-version: [18, 20, 22]
steps:
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ matrix.node-version }}
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: artifact-npm-binary-distributions
path: ./npm-binary-distributions
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: artifact-pkg-node
path: ./node-pkg
- name: Create package.json
run: |
mkdir test
cd test
cat <<EOF > package.json
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"lint": "supa-mdx-lint --version"
},
"keywords": [],
"author": "",
"license": "ISC"
}
EOF
- name: Install test packages
working-directory: test
run: |
npm install ../npm-binary-distributions/linux-x64/*.tgz
npm install ../node-pkg/*.tgz
- name: Test lint script
working-directory: test
run: npm run lint

test-macos:
runs-on: macos-latest
needs: [node, npm-distributions]
strategy:
fail-fast: false
matrix:
node-version: [18, 20, 22]
steps:
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ matrix.node-version }}
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: artifact-npm-binary-distributions
path: ./npm-binary-distributions
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: artifact-pkg-node
path: ./node-pkg
- name: Create package.json
run: |
mkdir test
cd test
cat <<EOF > package.json
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"lint": "supa-mdx-lint --version"
},
"keywords": [],
"author": "",
"license": "ISC"
}
EOF
- name: Install test packages
working-directory: test
run: |
npm install ../npm-binary-distributions/darwin/*.tgz
npm install ../node-pkg/*.tgz
- name: Test lint script
working-directory: test
run: npm run lint

test-windows:
runs-on: windows-latest
needs: [node, npm-distributions]
strategy:
fail-fast: false
matrix:
node-version: [18, 20, 22]
steps:
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ matrix.node-version }}
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: artifact-npm-binary-distributions
path: ./npm-binary-distributions
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: artifact-pkg-node
path: ./node-pkg
- name: List root directory contents
shell: cmd
run: dir
- name: List npm-binary-distributions directory contents
shell: cmd
run: |
dir npm-binary-distributions
dir npm-binary-distributions\win32-x64
- name: List node-pkg directory contents
shell: cmd
run: dir node-pkg
- name: Create package.json
shell: pwsh
run: |
mkdir test
cd test
$json = @"
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"lint": "supa-mdx-lint --version"
},
"keywords": [],
"author": "",
"license": "ISC"
}
"@
$json | Out-File -FilePath package.json -Encoding utf8
- name: Unpack binary tarball
shell: pwsh
run: |
$tarballPath = Get-ChildItem -Path npm-binary-distributions\win32-x64\*.tgz | Select-Object -First 1
tar -xzf $tarballPath.FullName -C npm-binary-distributions\win32-x64
Get-ChildItem -Path npm-binary-distributions\win32-x64
- name: Install binary
run: |
cd test
npm install ..\npm-binary-distributions\win32-x64
- name: Unpack node-pkg tarball
shell: pwsh
run: |
$tarballPath = Get-ChildItem -Path node-pkg\*.tgz | Select-Object -First 1
tar -xzf $tarballPath.FullName -C node-pkg
Get-ChildItem -Path node-pkg
- name: Install main package
run: |
cd test
npm install ..\node-pkg
- name: Test lint script
working-directory: test
run: npm run lint
3 changes: 3 additions & 0 deletions packages/supa-mdx-lint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "@supabase/supa-mdx-lint",
"version": "0.1.6-pre",
"main": "src/index.js",
"bin": {
"supa-mdx-lint": "src/index.js"
},
"scripts": {
"format": "prettier --write .",
"format:check": "prettier --check .",
Expand Down
2 changes: 2 additions & 0 deletions packages/supa-mdx-lint/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

//@ ts-check

"use strict";
Expand Down

0 comments on commit 7477321

Please sign in to comment.