Refreshed dependencies #80
This file contains hidden or 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: Go CI/CD | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| check-latest: true | |
| cache: true | |
| - name: Verify Go version | |
| run: go version | |
| - name: Run go vet | |
| run: go vet ./... | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| check-latest: true | |
| cache: true | |
| - name: Verify Go version | |
| run: go version | |
| - name: Verify dependencies | |
| run: go mod verify | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Run tests | |
| run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... | |
| - name: Print test coverage | |
| run: | | |
| go tool cover -func=coverage.txt | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| check-latest: true | |
| cache: true | |
| - name: Verify Go version | |
| run: go version | |
| - name: Verify dependencies | |
| run: go mod verify | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Build | |
| run: go build -v | |
| - name: Verify binary | |
| run: | | |
| if [ ! -f "darkness" ]; then | |
| echo "Build failed: binary not created" | |
| exit 1 | |
| fi | |
| echo "Build succeeded: binary created" | |
| ./darkness --version || echo "Binary exists but may not support --version flag" | |
| integration-test: | |
| name: Integration Test | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| check-latest: true | |
| cache: true | |
| - name: Verify Go version | |
| run: go version | |
| - name: Verify dependencies | |
| run: go mod verify | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Build darkness binary | |
| run: go build -v | |
| - name: Clone thecsw.github.io repository | |
| run: | | |
| git clone --depth 1 https://github.com/thecsw/thecsw.github.io.git /tmp/thecsw.github.io | |
| - name: Run darkness build on thecsw.github.io | |
| run: | | |
| cd /tmp/thecsw.github.io | |
| # Capture the output of darkness build | |
| BUILD_OUTPUT=$($GITHUB_WORKSPACE/darkness build | tee /dev/stderr) | |
| # Check if build was successful | |
| if [ $? -ne 0 ]; then | |
| echo "Integration test failed: darkness build failed" | |
| exit 1 | |
| fi | |
| # Extract the number of processed files from the output | |
| PROCESSED_FILES=$(echo "$BUILD_OUTPUT" | grep -oP "Processed \K[0-9]+" || echo "0") | |
| echo "Number of files processed: $PROCESSED_FILES" | |
| # Check if at least 100 files were processed | |
| if [ "$PROCESSED_FILES" -lt 100 ]; then | |
| echo "Integration test failed: Expected at least 100 files to be processed, but only $PROCESSED_FILES files were processed" | |
| exit 1 | |
| fi | |
| echo "Integration test passed: darkness build completed successfully, processed $PROCESSED_FILES files" |