This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: moved publish.yml into ci.yml * renamed ci to cicd
- Loading branch information
1 parent
8161ac0
commit 875a0f7
Showing
3 changed files
with
259 additions
and
264 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,259 @@ | ||
name: CI/CD | ||
on: | ||
push: | ||
branches: | ||
- development | ||
- master | ||
pull_request: | ||
jobs: | ||
test: | ||
if: ${{ github.event.pusher.email != 'action@github.com' }} | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7.x | ||
architecture: x64 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14.x | ||
- name: Install dependencies | ||
run: | | ||
pip install pipenv | ||
pipenv install --dev --system | ||
cd game_frontend | ||
yarn --frozen-lockfile | ||
- name: Run Javascript tests | ||
run: | | ||
cd game_frontend | ||
yarn lint | ||
yarn test --coverage | ||
- name: Bundle Frontend | ||
env: | ||
NODE_ENV: production | ||
run: | | ||
cd game_frontend | ||
node djangoBundler.js | ||
- name: Run Python tests | ||
run: python all_tests.py -c --no-docker-container-tests | ||
- name: Run Cypress tests | ||
uses: cypress-io/github-action@v2 | ||
with: | ||
install: false | ||
start: python ../run.py -c | ||
working-directory: game_frontend | ||
wait-on: http://localhost:8000 | ||
wait-on-timeout: 400 | ||
record: true | ||
env: | ||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
|
||
test-aimmo-game: | ||
if: ${{ github.event.pusher.email != 'action@github.com' }} | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Build docker image | ||
run: | | ||
cd aimmo-game | ||
docker build -t ocadotechnology/aimmo-game:test --target tester . | ||
- name: Run tests | ||
run: docker run -i -p 5000:5000 ocadotechnology/aimmo-game:test /bin/bash -c "coverage run setup.py test && coverage xml" | ||
- name: Get the coverage data from the container | ||
run: | | ||
read CONTAINERID <<< $(docker ps --all -q | head -1) | ||
docker cp -a $CONTAINERID:.coverage $(pwd)/.coverage | ||
docker cp -a $CONTAINERID:coverage.xml $(pwd)/coverage.xml | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
|
||
test-aimmo-game-creator: | ||
if: ${{ github.event.pusher.email != 'action@github.com' }} | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Build docker image | ||
run: | | ||
cd aimmo-game-creator | ||
docker build -t ocadotechnology/aimmo-game-creator:test --target tester . | ||
- name: Run tests | ||
run: docker run -i -p 5000:5000 ocadotechnology/aimmo-game-creator:test /bin/bash -c "coverage run setup.py test && coverage xml" | ||
- name: Get the coverage data from the container | ||
run: | | ||
read CONTAINERID <<< $(docker ps --all -q | head -1) | ||
docker cp -a $CONTAINERID:.coverage $(pwd)/.coverage | ||
docker cp -a $CONTAINERID:coverage.xml $(pwd)/coverage.xml | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
|
||
test-aimmo-game-worker: | ||
if: ${{ github.event.pusher.email != 'action@github.com' }} | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Build docker image | ||
run: | | ||
cd aimmo-game-worker | ||
docker build -t ocadotechnology/aimmo-game-worker:test --target tester . | ||
- name: Run tests | ||
run: docker run -i -p 5000:5000 ocadotechnology/aimmo-game-worker:test /bin/bash -c "coverage run setup.py test && coverage xml" | ||
- name: Get the coverage data from the container | ||
run: | | ||
read CONTAINERID <<< $(docker ps --all -q | head -1) | ||
docker cp -a $CONTAINERID:.coverage $(pwd)/.coverage | ||
docker cp -a $CONTAINERID:coverage.xml $(pwd)/coverage.xml | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
|
||
publish-python: | ||
name: Publish aimmo PyPi package | ||
needs: [test, test-aimmo-game, test-aimmo-game-creator, test-aimmo-game-worker] | ||
if: github.event_name == 'push' && github.event.pusher.email != 'action@github.com' | ||
runs-on: ubuntu-18.04 | ||
env: | ||
NODE_ENV: production | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7.x | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14.x | ||
- name: Install frontend dependencies | ||
run: | | ||
cd game_frontend | ||
yarn --frozen-lockfile | ||
- name: Install wheel | ||
run: pip install wheel | ||
- name: Build worker wheel | ||
run: ./aimmo_runner/build_worker_wheel.sh | ||
- name: Bundle Frontend | ||
run: | | ||
cd game_frontend | ||
node djangoBundler.js | ||
- name: Set branch | ||
id: branch | ||
run: | | ||
echo "::set-output name=branch::${GITHUB_REF##*/}" # get the substring from GITHUB_REF after the last '/' | ||
- name: Release aimmo | ||
uses: ocadotechnology/python-semantic-release@updated-beta-releases | ||
with: | ||
github_token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} | ||
pypi_token: ${{ secrets.PYPI_TOKEN }} | ||
branch: ${{ steps.branch.outputs.branch }} | ||
build: ${{ github.run_number }} | ||
|
||
publish-docker-images: | ||
name: Publish aimmo Docker images | ||
needs: [test, test-aimmo-game, test-aimmo-game-creator, test-aimmo-game-worker] | ||
if: github.event_name == 'push' && github.event.pusher.email != 'action@github.com' | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Set docker tag | ||
id: docker_tag | ||
run: | | ||
echo "::set-output name=tag::${GITHUB_REF:11}" # this is either branch name or tag after first character ('v') | ||
- name: Build and push aimmo-game image | ||
id: game | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: aimmo-game | ||
file: aimmo-game/Dockerfile | ||
tags: ocadotechnology/aimmo-game:${{ steps.docker_tag.outputs.tag }} | ||
target: runner | ||
push: true | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
- name: Build and push aimmo-game-creator image | ||
id: game_creator | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: aimmo-game-creator | ||
file: aimmo-game-creator/Dockerfile | ||
tags: ocadotechnology/aimmo-game-creator:${{ steps.docker_tag.outputs.tag }} | ||
target: runner | ||
push: true | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
- name: Image digest | ||
run: | | ||
echo ${{ steps.game.outputs.digest }} | ||
echo ${{ steps.game_creator.outputs.digest }} | ||
notify-semaphore: | ||
name: Notify Semaphore | ||
needs: [publish-python, publish-docker-images] | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Notify Semaphore (Staging) | ||
run: curl -d POST -v https://semaphoreci.com/api/v1/projects/${SEMAPHORE_PROJECT_ID}/master/build?auth_token=${SEMAPHORE_API_AUTH} | ||
env: | ||
SEMAPHORE_PROJECT_ID: ${{ secrets.SEMAPHORE_PROJECT_ID }} | ||
SEMAPHORE_API_AUTH: ${{ secrets.SEMAPHORE_API_AUTH }} | ||
|
||
merge-master-into-development: | ||
name: Merge master into development after release | ||
needs: [publish-python, publish-docker-images] | ||
if: github.ref == 'refs/heads/master' | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Checkout development branch | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
ref: development | ||
persist-credentials: false | ||
- name: Setup git username | ||
run: | | ||
git config --global user.name "github-actions" | ||
git config --global user.email "action@github.com" | ||
- name: Merge master into development | ||
run: | | ||
git merge origin/master | ||
git remote add authed-origin https://${GH_TOKEN}@github.com/ocadotechnology/aimmo.git > /dev/null 2>&1 | ||
git push --quiet --set-upstream authed-origin development | ||
env: | ||
GH_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }} |
Oops, something went wrong.