remove comment in toml #1359
Workflow file for this run
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
name: CI | |
on: | |
push: | |
release: | |
types: [released] | |
env: | |
REGISTRY: "ghcr.io" | |
REGISTRY_BASE_URI: ghcr.io/nrel/alfalfa | |
jobs: | |
pre-commit: | |
name: Pre-commit checks | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" | |
- name: Run pre-commit | |
uses: pre-commit/[email protected] | |
with: | |
extra_args: --all-files | |
unit-tests: | |
name: Run unit tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" | |
- name: Install poetry | |
uses: abatilo/actions-poetry@v3 | |
with: | |
poetry-version: 1.8.3 | |
- name: Install poetry dependencies | |
run: | | |
poetry install | |
- name: Runner Details | |
run: | | |
cat /etc/issue | |
python --version | |
- name: Start dependencies | |
run: | | |
printenv | |
docker compose up -d mongo redis minio mc | |
- name: Run tests with pytest | |
run: | | |
poetry run pytest | |
simulation-tests: | |
name: Run simulation tests in worker | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build | |
uses: docker/bake-action@v4 | |
with: | |
files: docker-compose.yml, docker-compose.dev.yml | |
set: | | |
web.cache-from=type=gha,scope=web:${{ github.ref_name }} | |
worker.cache-from=type=gha,scope=worker:${{ github.ref_name }} | |
worker.output=type=docker | |
# only need to start the worker which saves time here because | |
# the webpack calling on the web container for .dev.yml can take some | |
# time. | |
- name: Build and run stack | |
env: | |
GIT_COMMIT: ${{ github.sha }} | |
run: | | |
printenv | |
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d worker mongo redis minio mc goaws | |
- name: Dump docker logs before tests | |
uses: jwalton/gh-docker-logs@v2 | |
- name: Run job tests in Docker worker container | |
run: | | |
sleep 30 | |
docker exec alfalfa-worker-1 bash -c "cd /alfalfa && poetry run pytest -m docker tests/jobs -o log_cli=true -o log_level=info" | |
- name: Dump docker logs on failure | |
if: failure() | |
uses: jwalton/gh-docker-logs@v2 | |
integration-tests: | |
name: Run integration tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" | |
- name: Install poetry | |
uses: abatilo/actions-poetry@v3 | |
with: | |
poetry-version: 1.8.3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build | |
uses: docker/bake-action@v4 | |
with: | |
files: docker-compose.yml | |
set: | | |
web.cache-from=type=gha,scope=web:${{ github.ref_name }} | |
web.output=type=docker | |
worker.cache-from=type=gha,scope=worker:${{ github.ref_name }} | |
worker.output=type=docker | |
- name: Run stack | |
env: | |
GIT_COMMIT: ${{ github.sha }} | |
run: | | |
printenv | |
docker compose up -d --scale worker=2 | |
- name: Wait for web server | |
uses: nev7n/wait_for_response@v1 | |
with: | |
url: "http://localhost/" | |
responseCode: 200 | |
timeout: 120000 | |
interval: 500 | |
- name: Dump docker logs before tests | |
uses: jwalton/gh-docker-logs@v2 | |
- name: Install dependencies | |
run: poetry install | |
- name: Run API tests with pytest | |
run: | | |
poetry run pytest --timeout=120 -m api | |
- name: Run integration tests with pytest | |
run: | | |
poetry run pytest --timeout=600 -m "integration" | |
- name: Run worker scale tests with pytest | |
run: | | |
poetry run pytest -m "scale" | |
- name: Dump docker logs on failure | |
if: failure() | |
uses: jwalton/gh-docker-logs@v2 | |
integration-tests-historian: | |
name: Run integration tests with historian | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" | |
- name: Install poetry | |
uses: abatilo/actions-poetry@v3 | |
with: | |
poetry-version: 1.8.3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build | |
uses: docker/bake-action@v4 | |
with: | |
load: true | |
files: docker-compose.yml, docker-compose.dev.yml, docker-compose.historian.yml | |
set: | | |
web.cache-from=type=gha,scope=web:${{ github.ref_name }} | |
web.output=type=docker | |
worker.cache-from=type=gha,scope=worker:${{ github.ref_name }} | |
worker.output=type=docker | |
grafana.cache-from=type=gha,scope=grafana:${{ github.ref_name }} | |
grafana.output=type=docker | |
- name: Build and run stack | |
env: | |
GIT_COMMIT: ${{ github.sha }} | |
run: | | |
export HISTORIAN_ENABLE=true | |
printenv | |
docker compose -f docker-compose.yml -f docker-compose.historian.yml up -d --scale worker=2 | |
- name: Wait for web server | |
uses: nev7n/wait_for_response@v1 | |
with: | |
url: "http://localhost/" | |
responseCode: 200 | |
timeout: 120000 | |
interval: 500 | |
- name: Dump docker logs before tests | |
uses: jwalton/gh-docker-logs@v2 | |
- name: Install dependencies | |
run: poetry install | |
- name: Run API tests with pytest | |
run: | | |
poetry run pytest --timeout=120 -m api | |
- name: Run integration tests with pytest | |
run: | | |
poetry run pytest --timeout=600 -m "integration" | |
- name: Run worker scale tests with pytest | |
run: | | |
poetry run pytest -m "scale" | |
- name: Dump docker logs on failure | |
if: failure() | |
uses: jwalton/gh-docker-logs@v2 | |
publish: | |
needs: [pre-commit, unit-tests, simulation-tests, integration-tests, integration-tests-historian] | |
runs-on: ubuntu-latest | |
if: github.actor != 'dependabot[bot]' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Log into container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
uses: docker/metadata-action@v5 | |
id: meta | |
with: | |
tags: | | |
type=ref,event=branch | |
type=sha | |
type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }} | |
type=semver,pattern={{major}},enable=${{ github.event_name == 'release' }} | |
type=semver,pattern={{major}}.{{minor}},enable=${{ github.event_name == 'release' }} | |
type=edge | |
- name: Expose GitHub Runtime | |
uses: crazy-max/ghaction-github-runtime@v3 | |
- name: Build Push | |
run: | | |
/usr/bin/docker buildx bake \ | |
--file docker-compose.yml \ | |
--file docker-compose.historian.yml \ | |
--set *.platform=linux/arm64,linux/amd64 \ | |
--set web.cache-from=type=gha,scope=web:${{ github.ref_name }} \ | |
--set worker.cache-from=type=gha,scope=worker:${{ github.ref_name }} \ | |
--set grafana.cache-from=type=gha,scope=grafana:${{ github.ref_name }} \ | |
--set web.cache-to=type=gha,mode=max,scope=web:${{ github.ref_name }} \ | |
--set worker.cache-to=type=gha,mode=max,scope=worker:${{ github.ref_name }} \ | |
--set grafana.cache-to=type=gha,mode=max,scope=grafana:${{ github.ref_name }} \ | |
--set worker.tags=${{ env.REGISTRY_BASE_URI }}/worker:${{ join(fromJson(steps.meta.outputs.json)['tags'],format(' --set worker.tags={0}/worker:', env.REGISTRY_BASE_URI)) }} \ | |
--set web.tags=${{ env.REGISTRY_BASE_URI }}/web:${{ join(fromJson(steps.meta.outputs.json)['tags'],format(' --set web.tags={0}/web:', env.REGISTRY_BASE_URI)) }} \ | |
--set grafana.tags=${{ env.REGISTRY_BASE_URI }}/grafana:${{ join(fromJson(steps.meta.outputs.json)['tags'],format(' --set grafana.tags={0}/grafana:', env.REGISTRY_BASE_URI)) }} \ | |
--push |