Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create first test workflow #5

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
45 changes: 45 additions & 0 deletions .github/workflows/ci:test.yml
Original file line number Diff line number Diff line change
@@ -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$'
20 changes: 14 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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 📺
Expand All @@ -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 }} ☄️
Expand All @@ -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
1 change: 1 addition & 0 deletions test/example-projects/meteor-2.13.3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
1 change: 1 addition & 0 deletions test/example-projects/meteor-2.13.3/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
1 change: 1 addition & 0 deletions test/example-projects/meteor-2.13.3/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
METEOR@2.13.3
13 changes: 13 additions & 0 deletions test/example-projects/meteor-2.13.3/index.mjs
Original file line number Diff line number Diff line change
@@ -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');
13 changes: 13 additions & 0 deletions test/example-projects/meteor-2.13.3/package-lock.json

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

10 changes: 10 additions & 0 deletions test/example-projects/meteor-2.13.3/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}