Skip to content

Merge pull request #2 from belka-tech/e2e_tests #20

Merge pull request #2 from belka-tech/e2e_tests

Merge pull request #2 from belka-tech/e2e_tests #20

Workflow file for this run

name: CI Workflow
on:
push:
branches:
- master
tags:
- '*'
pull_request:
jobs:
unit_test:
name: Unit Tests
runs-on: ubuntu-latest
container:
image: golang:1.21
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run unit tests
run: go test -v ./...
compile:
name: Build
runs-on: ubuntu-latest
container:
image: golang:1.21
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Compile Go application
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gauge-exporter -buildvcs=false -ldflags "-X main.appVersion=${{ github.ref_name }}"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: gauge-exporter
path: gauge-exporter
retention-days: 1
release:
name: Release Application
runs-on: ubuntu-latest
needs: [compile] # Ensure release only happens after compile
if: startsWith(github.ref, 'refs/tags/') # Only run on tags
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: gauge-exporter
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: gauge-exporter
asset_name: gauge-exporter
asset_content_type: application/octet-stream
e2e_test:
name: E2E Tests
runs-on: ubuntu-latest
needs: [compile] # Ensure release only happens after compile
steps:
- uses: actions/checkout@v3
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: gauge-exporter
- name: Make gauge-exporter executable
run: chmod +x ./gauge-exporter
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: Cache Composer packages
uses: actions/cache@v3
with:
path: e2e_tests/vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/e2e_tests/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: |
cd e2e_tests
composer install --prefer-dist -n --no-ansi
- name: Run E2E tests
run: |
cd e2e_tests
./vendor/bin/phpunit --testdox