| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- name: Develop PR - build test
- on:
- pull_request:
- branches:
- - develop
- push:
- branches:
- - develop
- jobs:
- backend:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- with:
- path: ./
- -
- name: Install just
- uses: extractions/setup-just@v1
- -
- name: Install Go
- uses: actions/setup-go@v4
- with:
- go-version: 'stable'
- # Saves us from having to redownload all modules
- - name: Go Mod cache
- uses: actions/cache@v3
- with:
- path: |
- ~/.cache/go-build
- ~/go/pkg/mod
- key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- -
- name: Test
- run: |
- just test
- - name: Get branch name
- shell: bash
- run: echo "BRANCH_NAME=$(echo ${GITHUB_REF} | tr / -)" >> $GITHUB_ENV
- - name: save coverage file
- uses: actions/upload-artifact@v3
- with:
- path: ./opencost/opencost/coverage.out
- name: coverage-${{ env.BRANCH_NAME }}-${{ github.sha }}
- -
- name: Build
- run: |
- just build-local
- - name: Submit Code Coverage
- uses: sonarsource/sonarqube-scan-action@master
- env:
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- submit-to-sonarqube:
- needs: backend
- name: Submit to sonar
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- with:
- fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- - name: Get branch name
- shell: bash
- run: echo "BRANCH_NAME=$(echo ${GITHUB_REF} | tr / -)" >> $GITHUB_ENV
- - name: Restore coverage file
- uses: actions/download-artifact@v3
- with:
- path: /tmp/coverage.out
- name: coverage-${{ env.BRANCH_NAME }}-${{ github.sha }}
- - name: copy output file
- shell: bash
- run: mv /tmp/coverage.out/coverage.out coverage.out
- - uses: sonarsource/sonarqube-scan-action@master
- env:
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - uses: geekyeggo/delete-artifact@v2
- with:
- name: coverage-${{ env.BRANCH_NAME }}-${{ github.sha }}
- - name: save report file
- uses: actions/upload-artifact@v3
- with:
- path: .scannerwork
- name: report-${{ env.BRANCH_NAME }}-${{ github.sha }}
- code-quality-gate:
- needs: submit-to-sonarqube
- name: Code Quality Gate
- if: github.ref != 'refs/heads/develop'
- runs-on: ubuntu-latest
- steps:
- - name: Get branch name
- shell: bash
- run: echo "BRANCH_NAME=$(echo ${GITHUB_REF} | tr / -)" >> $GITHUB_ENV
- - name: Restore report file
- uses: actions/download-artifact@v3
- with:
- path: /tmp/.scannerwork
- name: report-${{ env.BRANCH_NAME }}-${{ github.sha }}
- - name: copy output file
- shell: bash
- run: mv /tmp/.scannerwork .scannerwork
- - uses: sonarsource/sonarqube-quality-gate-action@master
- timeout-minutes: 5
- env:
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- - uses: geekyeggo/delete-artifact@v2
- with:
- name: report-${{ env.BRANCH_NAME }}-${{ github.sha }}
- frontend:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- with:
- path: ./
- -
- name: Install just
- uses: extractions/setup-just@v1
- -
- name: Install node
- uses: actions/setup-node@v3
- with:
- node-version: '18.3.0'
- - name: Get npm cache directory
- id: npm-cache-dir
- shell: bash
- run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- - uses: actions/cache@v3
- id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
- with:
- path: ${{ steps.npm-cache-dir.outputs.dir }}
- key: ${{ runner.os }}-node-${{ hashFiles('./ui/**/package-lock.json') }}
- restore-keys: |
- ${{ runner.os }}-node-
- -
- name: Build
- working-directory: ./ui
- run: |
- just build-local
|