From cfa230b8a6bc19124d248269e9f9e55fac58ab31 Mon Sep 17 00:00:00 2001 From: Hoernschen Date: Fri, 24 Nov 2023 12:46:48 +0100 Subject: [PATCH] Create eco-ci.yml --- .github/workflows/eco-ci.yml | 78 ++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/eco-ci.yml diff --git a/.github/workflows/eco-ci.yml b/.github/workflows/eco-ci.yml new file mode 100644 index 00000000..7bcea34c --- /dev/null +++ b/.github/workflows/eco-ci.yml @@ -0,0 +1,78 @@ +name: Dendrite + +on: + push: + branches: + - master + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + timeout-minutes: 10 + name: Unit tests + runs-on: ubuntu-latest + # Service containers to run with `container-job` + services: + # Label used to access the service container + postgres: + # Docker Hub image + image: postgres:13-alpine + # Provide the password for postgres + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: dendrite + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - uses: actions/checkout@v3 + - name: Install libolm + run: sudo apt-get install libolm-dev libolm3 + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: "stable" + - uses: actions/cache@v3 + # manually set up caches, as they otherwise clash with different steps using setup-go with cache=true + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-stable-unit-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-stable-unit- + - name: Set up gotestfmt + uses: gotesttools/gotestfmt-action@v2 + with: + # Optional: pass GITHUB_TOKEN to avoid rate limiting. + token: ${{ secrets.GITHUB_TOKEN }} + - name: Eco CI Energy Estimation - Initialize + uses: green-coding-berlin/eco-ci-energy-estimation@v2 + with: + task: start-measurement + - run: go test -json -v ./... 2>&1 | gotestfmt -hide all + env: + POSTGRES_HOST: localhost + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: dendrite + - name: Eco CI Energy Estimation - Get Measurement + uses: green-coding-berlin/eco-ci-energy-estimation@v2 + with: + task: get-measurement + branch: master + - name: Eco CI Energy Estimation - End Measurement + uses: green-coding-berlin/eco-ci-energy-estimation@v2 + with: + task: display-results + branch: master