Skip to content

feat: #37 ECDH support for TOTP secret creation #85

feat: #37 ECDH support for TOTP secret creation

feat: #37 ECDH support for TOTP secret creation #85

Workflow file for this run

# Unit testing on vaious Go versions, such as Go 1.22 and later.
# It will test the generated password hash verifying with PHP and Python.
#
# This workflow caches images built with Docker and docker-compose to speed up its execution.
name: UnitTests
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
PATH_CACHE: /tmp/docker-img-arch
jobs:
go:
name: Run tests on Go via container
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Create image tag from file hash
uses: KEINOS/gh-action-hash-for-cache@main
id: imagetag
# Udate the hash if any file in the path has changed or the month has changed.
with:
path: |
./go.mod
./go.sum
./docker-compose.yml
./.github/Dockerfile
./.github/workflows/unit-tests.yml
variant: $(TZ=UTC-9 date '+%Y%m')
- name: Enable Cache
id: cache
uses: actions/cache@v4
with:
path: ${{ env.PATH_CACHE }}
key: ${{ steps.imagetag.outputs.hash }}
- name: Load cached Docker images if any
if: steps.cache.outputs.cache-hit == 'true'
run: |
docker load --input ${{ env.PATH_CACHE }}/${{ steps.imagetag.outputs.hash }}/go-totp_v1_22_1.tar
docker load --input ${{ env.PATH_CACHE }}/${{ steps.imagetag.outputs.hash }}/go-totp_latest_1.tar
- name: Pull base images if no-cache
if: steps.cache.outputs.cache-hit != 'true'
run: |
: # Pull images one-by-one for stability
docker pull golang:1.22-alpine
docker pull golang:alpine
- name: Build Docker images if no-cache
if: steps.cache.outputs.cache-hit != 'true'
run: |
docker-compose build
- name: Save/export built images to cache dir if no-cache
if: steps.cache.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ env.PATH_CACHE }}/${{ steps.imagetag.outputs.hash }}
docker save --output ${{ env.PATH_CACHE }}/${{ steps.imagetag.outputs.hash }}/go-totp_v1_22_1.tar go-totp_v1_22:latest
docker save --output ${{ env.PATH_CACHE }}/${{ steps.imagetag.outputs.hash }}/go-totp_latest_1.tar go-totp_latest:latest
- name: Run tests on Go 1.22
run: docker-compose run v1_22
- name: Run tests on latest Go
run: docker-compose run latest