forked from zestedesavoir/zds-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migration de la CI de travis à Github Actions (zestedesavoir#5994)
* remove .travis.yml * fix coverage * @Amaury remarks * remplace le push de la doc * Améliore la forme du fichier de workflow - Ajoute plein de lignes vide pour pouvoir plus facilement scanner le fichier. - Renomme toute les sections pour mieux scanner le log de GitHub Actions. - Explicite les versions utilisées dans ce log pour ne pas se faire surprendre. - Ajoute des commentaires expliquant en une phrase ce que fait chaque job. * GitHub n'aime pas les commentaires, semble-t-il. * Revert "GitHub n'aime pas les commentaires […]" This reverts commit 08b65c1. * Petite erreur YAML passée inaperçue * Rassemble toutes les versions dans l'environnement. - Toutes les versions des divers services utilisés par la CI sont précisées tout en haut du fichier, en tant que variables d'environnement. * Plus de cohérence de nommage avec GitHub * La tâche push_doc ne tourne pas du tout sur une PR - Modifie la CI avec un test au niveau de la tâche directement, afin qu'elle ne soit pas du tout démarrée si on est sur une PR. * Petite erreur de syntaxe * Pas d'environnement dans les services - GitHub Actions ne permet pas d'utiliser les variables d'environnement hors des noms, des tests (`if`) et des variables passées à des actions (`with`). Donc, pas dans les définitions de services. Par conséquent, nous sommes forcés de renseigner les versions en dur. Pour référence, j'ai gardé les versions en haut du fichier avec un commentaire précisant clairement qu'il faut mettre à jour les deux. * Final rename, I guess * Renomme test.yml en ci.yml Le nom est plus représentatif de tout ce que ça fait (beaucoup plus que juste des tests). * On n'est pas à un renomamge près * Retire une installation explicite inutile Remarque de Situphen Co-authored-by: Amaury Carrade <[email protected]>
- Loading branch information
1 parent
4d6747f
commit 9d0e60f
Showing
16 changed files
with
336 additions
and
648 deletions.
There are no files selected for viewing
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,285 @@ | ||
name: CI | ||
|
||
on: ["push", "pull_request"] | ||
|
||
env: | ||
NODE_VERSION: "12" | ||
PYTHON_VERSION: "3.7" | ||
MARIADB_VERSION: "10.4.10" | ||
|
||
# As GitHub Action does not allow environment variables | ||
# to be used in services definitions, these are only for | ||
# reference. If you update these versions, you HAVE TO | ||
# update the versions in the services definitions of the | ||
# test job. | ||
ELASTICSEARCH_VERSION: "5.5.2" | ||
MEMCACHED_VERSION: "1.6" | ||
|
||
jobs: | ||
# Lint the Python back-end with flake8. | ||
lint-back: | ||
name: Lint back-end | ||
runs-on: ubuntu-18.04 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ env.PYTHON_VERSION }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "${{ env.PYTHON_VERSION }}" | ||
|
||
- name: Install python dependencies | ||
run: pip install flake8 | ||
|
||
- name: Lint back-end | ||
run: make lint-back | ||
|
||
# Build the documentation and upload it as an artifact. | ||
build-doc: | ||
name: Build Sphinx documentation | ||
runs-on: ubuntu-18.04 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ env.PYTHON_VERSION }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "${{ env.PYTHON_VERSION }}" | ||
|
||
- name: Upgrade pip | ||
run: pip install --upgrade pip | ||
|
||
- name: Retrieve pip cache directory | ||
id: pip-cache | ||
run: echo "::set-output name=dir::$(pip cache dir)" | ||
|
||
- name: Cache pip packages | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.pip-cache.outputs.dir }} | ||
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Install python dependencies | ||
run: pip install -r requirements-dev.txt | ||
|
||
- name: Build documentation | ||
run: make generate-doc | ||
|
||
- name: Upload documentation as an artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: doc | ||
path: doc/build/html | ||
retention-days: 1 | ||
|
||
# Build the website front-end and upload built assets as an artifact. | ||
build-front: | ||
name: Lint and build front-end | ||
runs-on: ubuntu-18.04 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up NodeJS ${{ env.NODE_VERSION }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: "${{ env.NODE_VERSION }}" | ||
|
||
- name: Retrieve yarn cache directory | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- name: Cache Node modules | ||
uses: actions/cache@v2 | ||
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: Install front-end | ||
run: make install-front | ||
|
||
- name: Lint front-end | ||
run: make lint-front | ||
|
||
- name: Build front-end | ||
run: make build-front | ||
|
||
- name: Upload font-end assets for subsequent tests | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: assets | ||
path: dist | ||
retention-days: 1 | ||
|
||
# Test the zds-site project. | ||
# Install the project, using assets created during the previous job, | ||
# and install elasticsearch & memcache as a service. Then, run the tests | ||
# in a matrix build to parallelize multiple components. | ||
test: | ||
name: Install and test zds-site | ||
needs: build-front | ||
runs-on: ubuntu-18.04 | ||
|
||
strategy: | ||
matrix: | ||
module: | ||
[ | ||
"zds.tutorialv2", | ||
"zds.member zds.gallery zds.searchv2 zds.middlewares zds.pages", | ||
"zds.forum zds.featured zds.mp zds.notification zds.utils", | ||
] | ||
|
||
services: | ||
elasticsearch: | ||
image: "elasticsearch:5.5.2" | ||
ports: | ||
- "9200:9200" | ||
env: | ||
"http.host": "0.0.0.0" | ||
"transport.host": "127.0.0.1" | ||
"xpack.security.enabled": false | ||
"ES_JAVA_OPTS": "-Xms512m -Xmx512m" | ||
options: >- | ||
-e="discovery.type=single-node" | ||
--health-cmd="curl http://localhost:9200/_cluster/health" | ||
--health-interval=10s | ||
--health-timeout=5s | ||
--health-retries=10 | ||
memcached: | ||
image: "memcached:1.6" | ||
ports: | ||
- "11211:11211" | ||
|
||
steps: | ||
- name: Shutdown Ubuntu MySQL | ||
run: sudo service mysql stop | ||
|
||
- name: Set up MariaDB ${{ env.MARIADB_VERSION }} | ||
uses: getong/[email protected] | ||
with: | ||
character set server: "utf8mb4" | ||
collation server: "utf8mb4_unicode_ci" | ||
mariadb version: "${{ env.MARIADB_VERSION }}" | ||
mysql database: "ci_db_name" | ||
mysql root password: "ci_root_password" | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Download previously built assets | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: assets | ||
path: dist | ||
|
||
- name: Upgrade pip | ||
run: | | ||
pip install --upgrade pip | ||
- name: Retrieve pip cache directory | ||
id: pip-cache | ||
run: | | ||
echo "::set-output name=dir::$(pip cache dir)" | ||
- name: Cache pip packages | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.pip-cache.outputs.dir }} | ||
key: ${{ runner.os }}-pip-${{ hashFiles('requirements*.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Cache Node modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('zmd/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Set up Python ${{ env.PYTHON_VERSION }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "${{ env.PYTHON_VERSION }}" | ||
|
||
- name: Set up NodeJS ${{ env.NODE_VERSION }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: "${{ env.NODE_VERSION }}" | ||
|
||
- name: Install Python dependencies | ||
run: pip install -r requirements-ci.txt | ||
|
||
- name: Build and start zmarkdown | ||
run: | | ||
make zmd-install | ||
make zmd-start | ||
- name: Run tests for ${{ matrix.module }} | ||
run: | | ||
export PATH="$PATH:$GECKOWEBDRIVER" | ||
coverage run --source='.' manage.py test -v=2 --keepdb --settings zds.settings.ci_test ${{ matrix.module }} | ||
- name: Analyze coverage | ||
shell: bash -l {0} | ||
run: | | ||
echo $COVERALLS_FLAG_NAME | ||
python -m pip install coveralls | ||
coveralls | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.github_token }} | ||
COVERALLS_PARALLEL: true | ||
COVERALLS_FLAG_NAME: "${{ matrix.module }}" | ||
|
||
# Push coverage data to Coveralls. | ||
coverage: | ||
name: Push coverage to Coveralls | ||
needs: test | ||
runs-on: ubuntu-18.04 | ||
|
||
steps: | ||
- name: Set up Python ${{ env.PYTHON_VERSION }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "${{ env.PYTHON_VERSION }}" | ||
|
||
- name: Upload coverage data | ||
run: | | ||
python -m pip install coveralls | ||
coveralls --finish | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# If we're on the dev branch (i.e. for merged pull requests), push the built | ||
# documentation to the gh-page branch. | ||
push_doc: | ||
name: Push documentation to GitHub Pages | ||
needs: ["build-doc", "test"] | ||
runs-on: ubuntu-18.04 | ||
if: "github.ref == 'refs/heads/dev'" | ||
|
||
steps: | ||
- name: Download previously built documentation | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: doc | ||
path: doc/build/html | ||
|
||
- name: Deploy to GitHub Pages | ||
uses: JamesIves/[email protected] | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
BRANCH: gh-pages | ||
FOLDER: doc/build/html | ||
CLEAN: true |
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,4 @@ | ||
-r requirements-dev.txt | ||
-r requirements-prod.txt | ||
|
||
coverage==5.3 |
Oops, something went wrong.