|
7 | 7 | branches: [ "horizon" ]
|
8 | 8 |
|
9 | 9 | jobs:
|
10 |
| - build: |
11 |
| - |
| 10 | + build-and-test: |
12 | 11 | runs-on: ubuntu-latest
|
13 | 12 |
|
14 | 13 | steps:
|
15 |
| - - uses: actions/checkout@v4 |
16 |
| - |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up Node.js |
| 18 | + uses: actions/setup-node@v4 |
17 | 19 | with:
|
18 |
| - node-version: 24 |
| 20 | + node-version: '24' |
| 21 | + cache: 'npm' |
19 | 22 |
|
20 |
| - - name: update and install |
| 23 | + - name: Install Chrome and ChromeDriver |
21 | 24 | run: |
|
22 |
| - npm update |
23 |
| - npm install |
| 25 | + # Get latest stable Chrome version |
| 26 | + export CHROME_VERSION=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_STABLE) |
| 27 | + echo "Chrome version: $CHROME_VERSION" |
| 28 | + |
| 29 | + # Download Chrome and ChromeDriver |
| 30 | + curl -L https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chrome-linux64.zip -o chrome-linux64.zip |
| 31 | + curl -L https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chromedriver-linux64.zip -o chromedriver-linux64.zip |
| 32 | + |
| 33 | + # Extract Chrome |
| 34 | + unzip chrome-linux64.zip |
| 35 | + |
| 36 | + # Set Chrome binary path for tests |
| 37 | + echo "GOOGLE_CHROME_BINARY=./chrome-linux64/chrome" >> $GITHUB_ENV |
| 38 | +
|
| 39 | + - name: Update Pyret to newest version |
| 40 | + run: npm update pyret-lang |
24 | 41 |
|
25 | 42 | - name: Install dependencies
|
26 |
| - run: npm run build |
| 43 | + run: npm ci --ignore-scripts |
| 44 | + |
| 45 | + - name: Install ChromeDriver with specific binary |
| 46 | + run: | |
| 47 | + npm install chromedriver --chromedriver_filepath=$PWD/chromedriver-linux64.zip |
| 48 | + npm install -g chromedriver --chromedriver_filepath=$PWD/chromedriver-linux64.zip |
| 49 | +
|
| 50 | + - name: Add node_modules/.bin to PATH |
| 51 | + run: echo "$PWD/node_modules/.bin" >> $GITHUB_PATH |
| 52 | + |
| 53 | + - name: Build web assets |
| 54 | + run: make web |
27 | 55 |
|
| 56 | + - name: Deploy CPO main |
| 57 | + run: make deploy-cpo-main |
| 58 | + |
| 59 | + - name: Set up test environment variables |
| 60 | + run: | |
| 61 | + echo "TEST_LOC=local" >> $GITHUB_ENV |
| 62 | + echo "BASE_URL=http://localhost:5000" >> $GITHUB_ENV |
| 63 | + echo "SESSION_SECRET=not-so-secret-for-testing" >> $GITHUB_ENV |
| 64 | + echo "PYRET=http://localhost:5000/js/cpo-main.jarr" >> $GITHUB_ENV |
| 65 | + echo "PORT=5000" >> $GITHUB_ENV |
| 66 | + echo "POSTMESSAGE_ORIGIN=*" >> $GITHUB_ENV |
| 67 | + echo "SHARED_FETCH_SERVER=https://code.pyret.org" >> $GITHUB_ENV |
| 68 | +
|
| 69 | + - name: Start application server |
| 70 | + run: | |
| 71 | + # Start the server in background |
| 72 | + node src/run.js & |
| 73 | + |
| 74 | + # Wait for server to be ready |
| 75 | + sleep 3 |
| 76 | + |
| 77 | + # Verify server is running |
| 78 | + curl -f http://localhost:5000 || (echo "Server failed to start" && exit 1) |
| 79 | +
|
| 80 | + - name: Run tests |
| 81 | + run: | |
| 82 | + # Set up virtual display for headless browser testing |
| 83 | + export DISPLAY=:99 |
| 84 | + Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & |
| 85 | + |
| 86 | + # Wait a bit more for everything to be ready |
| 87 | + sleep 3 |
| 88 | + |
| 89 | + # Run tests based on event type |
| 90 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 91 | + echo "Running PR tests (excluding modules)" |
| 92 | + npx mocha --grep modules --invert |
| 93 | + else |
| 94 | + echo "Running all tests" |
| 95 | + npx mocha |
| 96 | + fi |
0 commit comments