Skip to content

Commit

Permalink
Refactor GitHub Actions workflow for cross-platform compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
arvvoid committed Sep 25, 2024
1 parent 62231c3 commit e911158
Showing 1 changed file with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ on:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
arch: [amd64, arm64, 386]
exclude:
- os: windows-latest
arch: arm64
- os: macos-latest
arch: 386
env:
FISKALHRGO_TEST_CERT_PATH: ${{ secrets.FISKALHRGO_TEST_CERT_PATH }}
FISKALHRGO_TEST_CERT_PASSWORD: ${{ secrets.FISKALHRGO_TEST_CERT_PASSWORD }}
Expand All @@ -20,17 +28,46 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23.1'
go-version: 'stable'

- name: Build
run: go build -v ./...
- name: Set TEMP_DIR environment variable
run: echo "TEMP_DIR=$(mktemp -d)" >> $GITHUB_ENV
shell: bash

- name: Set TEMP_DIR environment variable for Windows
if: runner.os == 'Windows'
run: echo "TEMP_DIR=%TEMP%" >> $GITHUB_ENV
shell: cmd

# Decode and save the P12 certificate (needed for tests)
- name: Decode and save the P12 certificate
run: |
echo "$CIS_P12_BASE64" | base64 -d > /tmp/fiskal.p12
go run -mod=mod - <<EOF
package main
import (
"encoding/base64"
"io/ioutil"
"os"
)
func main() {
data, err := base64.StdEncoding.DecodeString(os.Getenv("CIS_P12_BASE64"))
if err != nil {
panic(err)
}
err = ioutil.WriteFile(os.Getenv("TEMP_DIR")+"/fiskal.p12", data, 0644)
if err != nil {
panic(err)
}
}
EOF
env:
CIS_P12_BASE64: ${{ secrets.CIS_P12_BASE64 }}

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
env:
FISKALHRGO_TEST_CERT_PATH: $TEMP_DIR/fiskal.p12

0 comments on commit e911158

Please sign in to comment.