seperate go test and container build
Some checks failed
build container / build-container (push) Has been cancelled

This commit is contained in:
guochao 2025-02-19 20:27:50 +08:00
parent fc98377c9a
commit 7ba2e2e82f
2 changed files with 31 additions and 21 deletions

View File

@ -7,27 +7,8 @@ env:
GOPROXY: ${{ vars.GOPROXY }} GOPROXY: ${{ vars.GOPROXY }}
jobs: jobs:
test:
runs-on: bookworm
steps:
- name: Setup apt mirror
run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }}
if: ${{ vars.DEBIAN_MIRROR && vars.DEBIAN_APT_SOURCES }}
- name: Setup Debian environment
run: apt update && apt install -y nodejs
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: 1.24.0
- name: Check out repository code
uses: actions/checkout@v4
- name: Run tests
run: go test -v ./...
build-container: build-container:
runs-on: bookworm runs-on: bookworm
needs:
- test
steps: steps:
- name: Setup apt mirror - name: Setup apt mirror
run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }} run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }}
@ -42,8 +23,8 @@ jobs:
run: echo "${{ secrets.ACTION_PACKAGE_WRITE_TOKEN }}" | podman login ${{ github.server_url }} -u ${{ github.repository_owner }} --password-stdin run: echo "${{ secrets.ACTION_PACKAGE_WRITE_TOKEN }}" | podman login ${{ github.server_url }} -u ${{ github.repository_owner }} --password-stdin
- name: Push Container Image - name: Push Container Image
run: REGISTRY=${{ github.server_url}}; REGISTRY=${REGISTRY##https://}; REGISTRY=${REGISTRY##http://}; podman push $REGISTRY/${{ github.repository }} docker://$REGISTRY/${{ github.repository }}:dev run: REGISTRY=${{ github.server_url}}; REGISTRY=${REGISTRY##https://}; REGISTRY=${REGISTRY##http://}; podman push $REGISTRY/${{ github.repository }} docker://$REGISTRY/${{ github.repository }}:dev
if: ${{ github.ref_type == "branch" && github.ref_name == "master" }} if: github.ref == 'refs/heads/master'
- name: Push Container Image with Tag and Update latest image - name: Push Container Image with Tag and Update latest image
run: REGISTRY=${{ github.server_url}}; REGISTRY=${REGISTRY##https://}; REGISTRY=${REGISTRY##http://}; podman push $REGISTRY/${{ github.repository }}; podman push $REGISTRY/${{ github.repository }} docker://$REGISTRY/${{ github.repository }}:${{ github.ref_name }} run: REGISTRY=${{ github.server_url}}; REGISTRY=${REGISTRY##https://}; REGISTRY=${REGISTRY##http://}; podman push $REGISTRY/${{ github.repository }}; podman push $REGISTRY/${{ github.repository }} docker://$REGISTRY/${{ github.repository }}:${{ github.ref_name }}
if: ${{ github.ref_type == "tag" }} if: startsWith(github.ref, 'refs/tags/')

View File

@ -0,0 +1,29 @@
name: run go test
on:
push:
paths:
- '**/*.go'
- go.mod
- go.lock
- go.work
env:
GOPROXY: ${{ vars.GOPROXY }}
jobs:
test:
runs-on: bookworm
steps:
- name: Setup apt mirror
run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }}
if: ${{ vars.DEBIAN_MIRROR && vars.DEBIAN_APT_SOURCES }}
- name: Setup Debian environment
run: apt update && apt install -y nodejs
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: 1.24.0
- name: Check out repository code
uses: actions/checkout@v4
- name: Run tests
run: go test -v ./...