diff --git a/.github/workflows/ci:test.yml b/.github/workflows/ci:test.yml new file mode 100644 index 0000000..7d57c85 --- /dev/null +++ b/.github/workflows/ci:test.yml @@ -0,0 +1,45 @@ +name: ci:test + +on: + push: + branches: + - main + pull_request: + merge_group: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + + test: + name: Continuous integration (test) + + strategy: + matrix: + platform: + - ubuntu-latest + meteor-version: + - local + test: + - test/example-projects/meteor-2.13.3 + + runs-on: ${{ matrix.platform }} + + timeout-minutes: 3 + + steps: + - name: Checkout ๐Ÿ›Ž๏ธ + uses: actions/checkout@v4 + + - name: Install ๐Ÿ’พ + uses: ./ + with: + working-directory: ${{ matrix.test }} + executable_version: ${{ matrix.meteor-version }} + + - name: Test ๐Ÿงช + working-directory: ${{ matrix.test }} + run: | + meteor npm start | grep '^done$' diff --git a/action.yml b/action.yml index 2432097..b470ed1 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,9 @@ inputs: description: 'Meteor version for the `meteor` executable. If set to `local` or not explicitly set, the `meteor` executable will have the version specified in .meteor/release (this may not work with alpha and beta builds). You can use `latest` as an alias for the latest Meteor release.' required: true default: 'local' + working-directory: + required: true + default: '.' outputs: ran-npm-install-hooks: description: "Whether npm install hooks were run." @@ -16,8 +19,12 @@ runs: run: echo "$HOME/.meteor" >> $GITHUB_PATH shell: bash + - name: Set env.METEOR_RELEASE_PATH ๐Ÿฅพ + run: echo "METEOR_RELEASE_PATH=${{ inputs.working-directory }}/.meteor/release" >> $GITHUB_ENV + shell: bash + - name: Set env.METEOR_LOCAL_RELEASE ๐Ÿ“ป - run: echo "METEOR_LOCAL_RELEASE=$(sed -n 's/^METEOR@\([0-9][0-9]*.*\)$/\1/p' .meteor/release)" >> $GITHUB_ENV + run: echo "METEOR_LOCAL_RELEASE=$(sed -n 's/^METEOR@\([0-9][0-9]*.*\)$/\1/p' ${{ env.METEOR_RELEASE_PATH }})" >> $GITHUB_ENV shell: bash - name: Set env.METEOR_EXECUTABLE_VERSION ๐Ÿ“บ @@ -31,16 +38,16 @@ runs: fi shell: bash - - name: Cache ~/.meteor (Meteor ${{ env.METEOR_EXECUTABLE_VERSION }} (.meteor/release is ${{ env.METEOR_LOCAL_RELEASE }})) ๐Ÿ’ฟ + - name: Cache ~/.meteor (Meteor ${{ env.METEOR_EXECUTABLE_VERSION }} (${{ env.METEOR_RELEASE_PATH }} is ${{ env.METEOR_LOCAL_RELEASE }})) ๐Ÿ’ฟ uses: actions/cache@v4 id: cache-meteor env: cache-name: cache-meteor with: path: ~/.meteor - key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.METEOR_EXECUTABLE_VERSION }}-${{ hashFiles('.meteor/release') }}-${{ hashFiles('.meteor/versions') }} + key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.METEOR_EXECUTABLE_VERSION }}-${{ hashFiles(env.METEOR_RELEASE_PATH) }}-${{ hashFiles('.meteor/versions') }} restore-keys: | - ${{ runner.os }}-${{ env.cache-name }}-${{ env.METEOR_EXECUTABLE_VERSION }}-${{ hashFiles('.meteor/release') }}- + ${{ runner.os }}-${{ env.cache-name }}-${{ env.METEOR_EXECUTABLE_VERSION }}-${{ hashFiles(env.METEOR_RELEASE_PATH) }}- ${{ runner.os }}-${{ env.cache-name }}-${{ env.METEOR_EXECUTABLE_VERSION }}- - name: Install Meteor ${{ env.METEOR_EXECUTABLE_VERSION }} โ˜„๏ธ @@ -59,16 +66,17 @@ runs: ${{ runner.os }}-${{ env.cache-name }}- ${{ runner.os }}- - - name: Cache ./node_modules ๐Ÿ’ฝ + - name: Cache ${{ inputs.working-directory }}/node_modules ๐Ÿ’ฝ uses: actions/cache@v4 id: cache-node-modules env: cache-name: cache-node-modules with: - path: ./node_modules + path: ${{ inputs.working-directory }}/node_modules key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - name: Install dependencies ๐Ÿ“ฆ if: steps.cache-node-modules.outputs.cache-hit != 'true' + working-directory: ${{ inputs.working-directory }} run: meteor npm clean-install shell: bash diff --git a/test/example-projects/meteor-2.13.3/.gitignore b/test/example-projects/meteor-2.13.3/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/test/example-projects/meteor-2.13.3/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/test/example-projects/meteor-2.13.3/.meteor/.gitignore b/test/example-projects/meteor-2.13.3/.meteor/.gitignore new file mode 100644 index 0000000..4083037 --- /dev/null +++ b/test/example-projects/meteor-2.13.3/.meteor/.gitignore @@ -0,0 +1 @@ +local diff --git a/test/example-projects/meteor-2.13.3/.meteor/release b/test/example-projects/meteor-2.13.3/.meteor/release new file mode 100644 index 0000000..6641d04 --- /dev/null +++ b/test/example-projects/meteor-2.13.3/.meteor/release @@ -0,0 +1 @@ +METEOR@2.13.3 diff --git a/test/example-projects/meteor-2.13.3/index.mjs b/test/example-projects/meteor-2.13.3/index.mjs new file mode 100644 index 0000000..7a0be41 --- /dev/null +++ b/test/example-projects/meteor-2.13.3/index.mjs @@ -0,0 +1,13 @@ +import assert from 'assert'; +import {addMilliseconds} from 'date-fns' + +const now = () => new Date(); +const timeout = 500; +const expected = addMilliseconds(now(), timeout); + +setTimeout(() => { + assert(now() >= expected); + console.debug('done'); +}, timeout); + +console.debug('init'); diff --git a/test/example-projects/meteor-2.13.3/package-lock.json b/test/example-projects/meteor-2.13.3/package-lock.json new file mode 100644 index 0000000..413a60a --- /dev/null +++ b/test/example-projects/meteor-2.13.3/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "meteor-2.13.3", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "date-fns": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.6.0.tgz", + "integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==" + } + } +} diff --git a/test/example-projects/meteor-2.13.3/package.json b/test/example-projects/meteor-2.13.3/package.json new file mode 100644 index 0000000..cd9ddc4 --- /dev/null +++ b/test/example-projects/meteor-2.13.3/package.json @@ -0,0 +1,10 @@ +{ + "name": "meteor-2.13.3", + "version": "1.0.0", + "scripts": { + "start": "meteor node index.mjs" + }, + "dependencies": { + "date-fns": "^3.6.0" + } +}