|
| 1 | +name: Build PR |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [opened, synchronize, reopened, edited] |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + container: |
| 9 | + image: node:18.20 |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4.1.0 |
| 12 | + - name: restore_cache |
| 13 | + uses: actions/cache@v4.3.0 |
| 14 | + with: |
| 15 | + key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }} |
| 16 | + path: node_modules/ |
| 17 | + restore-keys: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }} |
| 18 | + - name: Install Dependencies |
| 19 | + run: yarn --frozen-lockfile |
| 20 | + - name: Lint the codebase |
| 21 | + run: yarn lint |
| 22 | + - name: Run tests |
| 23 | + run: yarn test --colors --maxWorkers=2 |
| 24 | + - name: Run build |
| 25 | + run: yarn build |
| 26 | + harness-docker: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + container: |
| 29 | + image: node:18.20 |
| 30 | + env: |
| 31 | + executor: docker-harness |
| 32 | + install_manually: true |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v4.1.0 |
| 35 | + - name: Install nvm |
| 36 | + run: | |
| 37 | + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash |
| 38 | + export NVM_DIR="$HOME/.nvm" |
| 39 | + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" |
| 40 | + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" |
| 41 | + - name: Use Node.js 18.20.1 |
| 42 | + run: | |
| 43 | + export NVM_DIR="$HOME/.nvm" |
| 44 | + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" |
| 45 | + nvm install 18.20.1 |
| 46 | + nvm alias default 18.20.1 |
| 47 | + - name: Install Python and required packages |
| 48 | + run: | |
| 49 | + apt-get update |
| 50 | + apt-get install -y python3 python3-pip python3-venv |
| 51 | + - name: Set up Python virtual environment |
| 52 | + run: | |
| 53 | + python3 -m venv venv |
| 54 | + . venv/bin/activate |
| 55 | + pip install --upgrade pip |
| 56 | + pip install pipenv gunicorn |
| 57 | + pipenv --version # Verify pipenv is installed |
| 58 | + gunicorn --version # Verify gunicorn is installed |
| 59 | + if: env.install_manually |
| 60 | + - run: bash -c 'echo "0.0.0.0 httpbin.org" >> /etc/hosts' |
| 61 | + if: env.install_manually |
| 62 | + - run: git clone https://github.com/stoplightio/httpbin httpbin |
| 63 | + if: env.install_manually |
| 64 | + - run: | |
| 65 | + cd httpbin |
| 66 | + . ../venv/bin/activate |
| 67 | + pipenv requirements > requirements.txt |
| 68 | + pip3 install --no-cache-dir -r requirements.txt |
| 69 | + pip3 install --no-cache-dir ./ |
| 70 | + if: env.install_manually |
| 71 | + - run: | |
| 72 | + cd httpbin |
| 73 | + . ../venv/bin/activate |
| 74 | + gunicorn -b 0.0.0.0:80 httpbin:app -k gevent & |
| 75 | + sleep 15 # Wait for the server to start |
| 76 | + curl -I http://0.0.0.0:80 # Test server availability |
| 77 | + if: env.install_manually |
| 78 | + - name: Install Dependencies |
| 79 | + run: yarn --frozen-lockfile |
| 80 | + - name: Create CLI binary |
| 81 | + run: yarn build.binary |
| 82 | + - name: Run Harness |
| 83 | + run: yarn test.harness |
0 commit comments