Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test

on:
push:
branches: ['main']
pull_request:
branches: ['main']

jobs:
checks:
name: Lint and Test
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install dependencies
run: |
corepack enable
yarn install --immutable

- name: Type check
run: yarn tsc

- name: Check Lint & Format
run: yarn lint:check

- name: Run tests
run: yarn test

- name: Run build
run: yarn build
48 changes: 48 additions & 0 deletions .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Version Check

on:
pull_request:
branches: ['main']

jobs:
version-check:
name: Check Version Bump
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read

steps:
- name: Checkout PR
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Get PR version
id: pr_version
run: |
PR_VERSION=$(node -p "require('./package.json').version")
echo "version=$PR_VERSION" >> $GITHUB_OUTPUT

- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
path: main

- name: Get main version
id: main_version
run: |
MAIN_VERSION=$(node -p "require('./main/package.json').version")
echo "version=$MAIN_VERSION" >> $GITHUB_OUTPUT

- name: Compare versions
run: |
PR_VERSION="${{ steps.pr_version.outputs.version }}"
MAIN_VERSION="${{ steps.main_version.outputs.version }}"

if ! npx semver --range ">$MAIN_VERSION" "$PR_VERSION"; then
echo "Error: Version in PR ($PR_VERSION) is not higher than version in main ($MAIN_VERSION)"
exit 1
fi
echo "Version check passed: $PR_VERSION > $MAIN_VERSION"
31 changes: 18 additions & 13 deletions app/components/select-stage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export type SelectStageProps = {
setSong: Dispatch<Song | undefined>
}

const useDragAndDrop = (onFile: (file: ArrayBuffer, fileName: string) => Promise<void>) => {
const useDragAndDrop = (
onFile: (file: ArrayBuffer, fileName: string) => Promise<void>,
) => {
const [isDragging, setIsDragging] = useState(false)

useEffect(() => {
Expand Down Expand Up @@ -89,21 +91,24 @@ export const SelectStage = ({ setSong }: SelectStageProps) => {
const postHog = usePostHog()
const [loadingMessage, setLoadingMessage] = useState('')

const processFile = useCallback(async (file: ArrayBuffer, fileName: string) => {
postHog.capture('Selected midi file', {
'File Name': fileName,
})
setSong(undefined)
const processFile = useCallback(
async (file: ArrayBuffer, fileName: string) => {
postHog.capture('Selected midi file', {
'File Name': fileName,
})
setSong(undefined)

requestAnimationFrame(() => {
setLoadingMessage('Loading file...')
requestAnimationFrame(() => {
const song = new Midi(file.slice(0))
setSong(midiToSong(song, fileName))
setLoadingMessage('')
setLoadingMessage('Loading file...')
requestAnimationFrame(() => {
const song = new Midi(file.slice(0))
setSong(midiToSong(song, fileName))
setLoadingMessage('')
})
})
})
}, [postHog, setSong])
},
[postHog, setSong],
)

const { openFilePicker } = useFilePicker({
accept: ['audio/midi', 'audio/x-midi'],
Expand Down
156 changes: 108 additions & 48 deletions app/lib/__snapshots__/kmeans.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading