Skip to content

Commit

Permalink
feat(ansible): publish gabriel-stress-test tag immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar committed Jun 17, 2023
1 parent f5d866a commit 9c90ede
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 199 deletions.
198 changes: 0 additions & 198 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,86 +9,7 @@ on:
- master

jobs:
test:
runs-on: ubuntu-22.04
services:
rabbitmq:
image: rabbitmq
ports:
- 5672:5672
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50

- id: changed-files
name: Check changed files
run: python3 ci/check-changed-files.py | bash

- name: Set up JDK
if: steps.changed-files.outputs.gradle == '1'
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
cache: 'gradle'

- name: Test judgels-commons
if: steps.changed-files.outputs.judgels-commons == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-commons check

- name: Test judgels-grader-api
if: steps.changed-files.outputs.judgels-grader == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-grader-api check

- name: Test judgels-grader-engines
if: steps.changed-files.outputs.judgels-grader == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-grader-engines check

- name: Test judgels-grader-app
if: steps.changed-files.outputs.judgels-grader == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-grader-app check

- name: Test judgels-server-api
if: steps.changed-files.outputs.judgels-server == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-server-api check

- name: Test judgels-server-app
if: steps.changed-files.outputs.judgels-server == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-server-app check

- name: Set up node
if: steps.changed-files.outputs.yarn == '1'
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Get yarn cache directory path
if: steps.changed-files.outputs.yarn == '1'
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Use yarn cache
if: steps.changed-files.outputs.yarn == '1'
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Test judgels-client
if: steps.changed-files.outputs.judgels-client == '1'
run: |
cd judgels-client
export NODE_OPTIONS="--max-old-space-size=4096"
yarn install
yarn ci
build:
needs: test
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
env:
CONTAINER_REGISTRY_USERNAME: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
Expand All @@ -103,131 +24,12 @@ jobs:
ansible-galaxy collection install community.docker:3.4.5
pipx inject ansible-core docker six
- id: changed-files
name: Check changed files
run: python3 ci/check-changed-files.py | bash

- name: Set up JDK
if: steps.changed-files.outputs.gradle == '1'
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
cache: 'gradle'

- name: Set up node
if: steps.changed-files.outputs.yarn == '1'
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Get yarn cache directory path
if: steps.changed-files.outputs.yarn == '1'
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Use yarn cache
if: steps.changed-files.outputs.yarn == '1'
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Build judgels-server
if: steps.changed-files.outputs.judgels-server == '1'
run: ./deployment/scripts/build_judgels_server.sh

- name: Build judgels-client
if: steps.changed-files.outputs.judgels-client == '1'
run: ./deployment/scripts/build_judgels_client.sh

- name: Build judgels-grader
if: steps.changed-files.outputs.judgels-grader == '1'
run: ./deployment/scripts/build_judgels_grader.sh

deploy-web:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
env:
WEB_HOST: ${{ secrets.WEB_HOST }}
WEB_KNOWN_HOSTS: ${{ secrets.WEB_KNOWN_HOSTS }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 50

- id: changed-files
name: Check changed files
run: python3 ci/check-changed-files.py | bash

- name: Set up node
if: steps.changed-files.outputs.web == '1'
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Build web
if: steps.changed-files.outputs.web == '1'
run: |
cd web
yarn install
yarn build
- name: Install SSH key
if: steps.changed-files.outputs.web == '1'
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.WEB_PRIVATE_KEY }}
known_hosts: ${{ secrets.WEB_KNOWN_HOSTS }}

- name: Rsync web
if: steps.changed-files.outputs.web == '1'
run: rsync -avzh web/build/ root@${WEB_HOST}:/var/www/html/judgels --delete

deploy-tlx-staging:
needs: build
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50

- name: Check out deployment repository
uses: actions/checkout@v3
with:
repository: ${{ secrets.TLX_STAGING_DEPLOYMENT_REPOSITORY }}
token: ${{ secrets.TLX_STAGING_DEPLOYMENT_TOKEN }}
path: deployment/ansible/env

- name: Prepare staging environment SSH key
run: chmod 600 deployment/ansible/env/deployment_rsa

- id: changed-files
name: Check changed files
run: python3 ci/check-changed-files.py | bash

- name: Deploy judgels-server
if: steps.changed-files.outputs.judgels-server == '1'
run: |
eval "$(ssh-agent -s)"
ssh-add deployment/ansible/env/deployment_rsa
./deployment/scripts/deploy_judgels_server.sh
- name: Deploy judgels-client
if: steps.changed-files.outputs.judgels-client == '1'
run: |
eval "$(ssh-agent -s)"
ssh-add deployment/ansible/env/deployment_rsa
./deployment/scripts/deploy_judgels_client.sh
- name: Deploy judgels-grader
if: steps.changed-files.outputs.judgels-grader == '1'
run: |
eval "$(ssh-agent -s)"
ssh-add deployment/ansible/env/deployment_rsa
./deployment/scripts/deploy_judgels_grader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
source: build
force_source: yes
name: ghcr.io/ia-toki/judgels/grader
tag: gabriel-stress-test
push: yes
build:
path: "{{ playbook_dir }}/../../../judgels-backends/judgels-grader-app"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void run() {
});

try {
Thread.sleep((int) (Math.random() * 1000));
Thread.sleep((int) (Math.random() * 6000));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
Expand Down

0 comments on commit 9c90ede

Please sign in to comment.