Skip to content

Commit

Permalink
chore(ci): add job to run tests on hello-world as a student would
Browse files Browse the repository at this point in the history
  • Loading branch information
clechasseur committed Nov 8, 2023
1 parent e4ac92e commit 2516ba4
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,34 @@ jobs:

- name: Run exercism/typescript ci (checks config, lint code, and runs tests) for all exercises
run: yarn ci

impersonate:
# This job tries to run tests for the 'hello-world' exercise, but
# simulating what would happen if a student runs the tests standalone.
# We do this by removing all project files in the root.

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- name: Use Node.js 20.x
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
with:
node-version: 20.x

- name: Remove root project files
run: rm -f package.json yarn.lock .yarnrc.yml

- name: Move solution file so that tests pass
working-directory: exercises/practice/hello-world
run: |
rm -f hello-world.ts
cp ./.meta/proof.ci.ts hello-world.ts
- name: Install project dependencies
working-directory: exercises/practice/hello-world
run: yarn install --no-immutable

- name: Run tests
working-directory: exercises/practice/hello-world
run: yarn test
31 changes: 31 additions & 0 deletions .github/workflows/pr.ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,34 @@ jobs:
curl --url $"${PULL_REQUEST_URL}/files?per_page=100" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
jq -c '.[] | select(.status == "added" or .status == "modified") | select(.filename | match("\\.(js|jsx|ts|tsx|md|json)$")) | .filename' | \
xargs -r yarn dlx -p @babel/core -p @babel/node babel-node scripts/pr
impersonate:
# This job tries to run tests for the 'hello-world' exercise, but
# simulating what would happen if a student runs the tests standalone.
# We do this by removing all project files in the root.

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- name: Use Node.js 20.x
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
with:
node-version: 20.x

- name: Remove root project files
run: rm -f package.json yarn.lock .yarnrc.yml

- name: Move solution file so that tests pass
working-directory: exercises/practice/hello-world
run: |
rm -f hello-world.ts
cp ./.meta/proof.ci.ts hello-world.ts
- name: Install project dependencies
working-directory: exercises/practice/hello-world
run: yarn install --no-immutable

- name: Run tests
working-directory: exercises/practice/hello-world
run: yarn test

0 comments on commit 2516ba4

Please sign in to comment.