embedding shouldn't rely on another random dev server at :3000 for te… #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: code.pyret.org/ tests | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| defaults: | |
| run: | |
| working-directory: ./code.pyret.org | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Link pyret-lang | |
| run: | | |
| ln -s ../lang pyret | |
| cd ../lang && npm install && make phaseA-deps | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| - name: Install Chrome and ChromeDriver | |
| run: | | |
| # Get latest stable Chrome version | |
| export CHROME_VERSION=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_STABLE) | |
| echo "Chrome version: $CHROME_VERSION" | |
| # Download Chrome and ChromeDriver | |
| curl -L https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chrome-linux64.zip -o chrome-linux64.zip | |
| curl -L https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chromedriver-linux64.zip -o chromedriver-linux64.zip | |
| # Extract Chrome | |
| unzip chrome-linux64.zip | |
| # Set Chrome binary path for tests | |
| echo "GOOGLE_CHROME_BINARY=./chrome-linux64/chrome" >> $GITHUB_ENV | |
| - name: Install dependencies | |
| run: npm ci --ignore-scripts | |
| - name: Install ChromeDriver with specific binary | |
| run: | | |
| npm install chromedriver --chromedriver_filepath=$PWD/chromedriver-linux64.zip | |
| npm install -g chromedriver --chromedriver_filepath=$PWD/chromedriver-linux64.zip | |
| - name: Add node_modules/.bin to PATH | |
| run: echo "$PWD/node_modules/.bin" >> $GITHUB_PATH | |
| - name: Build web assets | |
| run: npm run build | |
| - name: Set up test environment variables | |
| run: | | |
| echo "TEST_LOC=local" >> $GITHUB_ENV | |
| echo "GOOGLE_CLIENT_ID=" >> $GITHUB_ENV | |
| echo "GOOGLE_CLIENT_SECRET=" >> $GITHUB_ENV | |
| echo "GOOGLE_API_KEY=" >> $GITHUB_ENV | |
| echo "GOOGLE_SERVER_API_KEY=" >> $GITHUB_ENV | |
| echo "GOOGLE_APP_ID=" >> $GITHUB_ENV | |
| echo "BASE_URL=http://localhost:4999" >> $GITHUB_ENV | |
| echo "LOG_URL=http://localhost:5002" >> $GITHUB_ENV | |
| echo "SESSION_SECRET=not-so-secret" >> $GITHUB_ENV | |
| echo "REDISCLOUD_URL=" >> $GITHUB_ENV | |
| echo "CURRENT_PYRET_RELEASE=" >> $GITHUB_ENV | |
| echo "PYRET=http://localhost:4999/js/cpo-main.jarr" >> $GITHUB_ENV | |
| echo "PORT=4999" >> $GITHUB_ENV | |
| echo "NODE_ENV=development" >> $GITHUB_ENV | |
| echo "SHARED_FETCH_SERVER=https://code.pyret.org" >> $GITHUB_ENV | |
| echo "URL_FILE_MODE=all-remote" >> $GITHUB_ENV | |
| echo "IMAGE_PROXY_BYPASS=true" >> $GITHUB_ENV | |
| echo "POSTMESSAGE_ORIGIN=*" >> $GITHUB_ENV | |
| - name: Start application server | |
| run: | | |
| # Start the server in background | |
| node src/run.js & | |
| # Wait for server to be ready | |
| sleep 3 | |
| # Verify server is running | |
| curl -f http://localhost:4999 || (echo "Server failed to start" && exit 1) | |
| - name: Run tests | |
| run: | | |
| # Wait a bit more for everything to be ready | |
| sleep 3 | |
| # Run tests based on event type | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| echo "Running PR tests (excluding modules)" | |
| npm run mocha -- --grep modules --invert | |
| else | |
| echo "Running all tests" | |
| npm run mocha | |
| fi |