diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..2cb9b1af9 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,61 @@ +--- +name: build-docker-image + +on: + pull_request: + types: + - opened + - synchronize + push: + branches: + - main + +jobs: + build: + name: Build Docker Image + runs-on: ubuntu-latest + services: + postgres: + env: + POSTGRES_DB: flexmeasures_test + POSTGRES_PASSWORD: flexmeasures_test + POSTGRES_USER: flexmeasures_test + image: postgres:latest + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build Docker Image + run: docker build -t flexmeasures:latest -f Dockerfile . + - name: Generate random secret key + run: echo "SECRET_KEY=$(python3 -c 'import secrets; print(secrets.token_hex(24))')" + >> .env + - name: Export SQLALCHEMY_DATABASE_URI + run: echo "SQLALCHEMY_DATABASE_URI=postgresql://flexmeasures_test:flexmeasures_test@127.0.0.1:5432/flexmeasures_test" + >> .env + - name: Keep running flexmeasures container in background + run: docker run -t -d --env-file .env --network=host --name fm-container flexmeasures:latest + - name: Execute database upgrade + run: docker exec --env-file .env fm-container flexmeasures + db upgrade + - name: Add toy user + run: docker exec --env-file .env fm-container flexmeasures + add toy-account + - name: Generate prices dummy data + run: .github/workflows/generate-dummy-price.sh + - name: Copy prices dummy data + run: docker cp prices-tomorrow.csv fm-container:/app/prices-tomorrow.csv + - name: Add beliefs + run: docker exec --env-file .env fm-container flexmeasures + add beliefs --sensor-id 1 --source toy-user prices-tomorrow.csv --timezone Europe/Amsterdam + - name: Export TOMORROW + run: echo "TOMORROW=$(date --date="next day" '+%Y-%m-%d')" + >> $GITHUB_ENV + - name: Add schedule + run: docker exec --env-file .env fm-container flexmeasures + add schedule for-storage --sensor-id 2 --consumption-price-sensor 1 + --start ${TOMORROW}T07:00+01:00 --duration PT12H + --soc-at-start 50% --roundtrip-efficiency 90% diff --git a/.github/workflows/generate-dummy-price.sh b/.github/workflows/generate-dummy-price.sh new file mode 100755 index 000000000..06ee67045 --- /dev/null +++ b/.github/workflows/generate-dummy-price.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e +set -x + +TOMORROW=$(date --date="next day" '+%Y-%m-%d') + +echo "Hour,Price +${TOMORROW}T00:00:00,10 +${TOMORROW}T01:00:00,11 +${TOMORROW}T02:00:00,12 +${TOMORROW}T03:00:00,15 +${TOMORROW}T04:00:00,18 +${TOMORROW}T05:00:00,17 +${TOMORROW}T06:00:00,10.5 +${TOMORROW}T07:00:00,9 +${TOMORROW}T08:00:00,9.5 +${TOMORROW}T09:00:00,9 +${TOMORROW}T10:00:00,8.5 +${TOMORROW}T11:00:00,10 +${TOMORROW}T12:00:00,8 +${TOMORROW}T13:00:00,5 +${TOMORROW}T14:00:00,4 +${TOMORROW}T15:00:00,4 +${TOMORROW}T16:00:00,5.5 +${TOMORROW}T17:00:00,8 +${TOMORROW}T18:00:00,12 +${TOMORROW}T19:00:00,13 +${TOMORROW}T20:00:00,14 +${TOMORROW}T21:00:00,12.5 +${TOMORROW}T22:00:00,10 +${TOMORROW}T23:00:00,7" > prices-tomorrow.csv diff --git a/documentation/changelog.rst b/documentation/changelog.rst index d80591d06..2256fbd08 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -17,6 +17,7 @@ Infrastructure / Support * Allow additional datetime conversions to quantitative time units, specifically, from timezone-naive and/or dayfirst datetimes, which can be useful when importing data [see `PR #831 `_] * Add a new tutorial to explain the use of the `AggregatorReporter` to compute the headroom and the `ProfitOrLossReporter` to compute the cost of running a process [see `PR #825 `_] +* Have our CI pipeline (GitHub Actions) build the Docker image and make a schedule [see `PR #800 `_] v0.15.1 | August 28, 2023 ============================