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

New Integration tests (example split continuation) #5492

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
71 changes: 71 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Integration Tests

on:
- pull_request
- push

jobs:
e2e_tests:
runs-on: ubuntu-latest
steps:
- name: Get the branch name
id: get_branch
run: echo "branch=$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}})" >> $GITHUB_OUTPUT

- name: Get the originating repository
id: get_repo
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "repo=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_OUTPUT
else
echo "repo=${{ github.repository }}" >> $GITHUB_OUTPUT
fi

- name: Repository Dispatch
env:
TOKEN: ${{ secrets.PAT_INTEGRATION_TESTS }}
run: |
curl -X POST https://api.github.com/repos/expressjs/examples/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H "Authorization: token $TOKEN" \
--data '{"event_type": "integration-tests", "client_payload": {"branch": "${{ steps.get_branch.outputs.branch }}", "repo": "${{ steps.get_repo.outputs.repo }}"}}'

# Wait for the workflow to start
sleep 60

# Get the latest workflow run
response=$(curl -H "Authorization: token $TOKEN" https://api.github.com/repos/expressjs/examples/actions/runs)
workflow_url=$(echo "$response" | jq -r '.workflow_runs[0].url')

status=""
start_time=$(date +%s)
timeout=$((10 * 60)) # timeout after 10 minutes

while [[ "$status" != "completed" && $(( $(date +%s) - start_time )) -lt $timeout ]]; do
echo "checking..."
sleep 10
response=$(curl -H "Authorization: token $TOKEN" $workflow_url)
status=$(echo "$response" | jq -r .status)
echo "current status: $status"
done

if [[ $(( $(date +%s) - start_time )) -ge $timeout ]]; then
echo "Workflow did not complete within the expected time"
fi

# Get the conclusion of the workflow run
conclusion=$(echo "$response" | jq -r .conclusion)

# Get the URL of the workflow run
html_url=$(echo "$response" | jq -r .html_url)
echo "Check the workflow run for details: $html_url"

if [[ "$status" == "completed" && "$conclusion" != "success" ]]; then
echo "Workflow completed but failed. Conclusion: $conclusion"
exit 1
fi

if [[ "$status" == "completed" && "$conclusion" == "success" ]]; then
echo "Workflow has been completed successfully"
exit 0
fi
13 changes: 1 addition & 12 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,8 @@ $ npm start

## Examples

To view the examples, clone the Express repo and install the dependencies:
To view the examples, checkout [this dedicated repository](https://github.com/expressjs/examples) and follow the instructions in the README.

```console
$ git clone https://github.com/expressjs/express.git --depth 1
$ cd express
$ npm install
```

Then run whichever example you want:

```console
$ node examples/content-negotiation
```

## Contributing

Expand Down
30 changes: 0 additions & 30 deletions examples/README.md

This file was deleted.

133 changes: 0 additions & 133 deletions examples/auth/index.js

This file was deleted.

2 changes: 0 additions & 2 deletions examples/auth/views/foot.ejs

This file was deleted.

20 changes: 0 additions & 20 deletions examples/auth/views/head.ejs

This file was deleted.

21 changes: 0 additions & 21 deletions examples/auth/views/login.ejs

This file was deleted.

9 changes: 0 additions & 9 deletions examples/content-negotiation/db.js

This file was deleted.

46 changes: 0 additions & 46 deletions examples/content-negotiation/index.js

This file was deleted.

19 changes: 0 additions & 19 deletions examples/content-negotiation/users.js

This file was deleted.

Loading