From 9fb841439cec970a45c205f0c1debb86b21c4c91 Mon Sep 17 00:00:00 2001 From: Tyler Nickerson Date: Wed, 25 Oct 2023 23:41:02 -0700 Subject: [PATCH] try --- .github/workflows/pr.yml | 99 ++++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 47 ------------------ .goreleaser.yaml | 41 ++++++++++++---- Dockerfile | 6 +++ justfile | 10 ++-- 5 files changed, 142 insertions(+), 61 deletions(-) create mode 100644 .github/workflows/pr.yml delete mode 100644 .github/workflows/test.yml create mode 100644 Dockerfile diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000..b809dd42 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,99 @@ +name: Build & Test + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + linux: + name: Build (Linux) + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup asdf + uses: asdf-vm/actions/setup@v2 + - name: Cache asdf + id: cache-asdf + uses: actions/cache@v3 + with: + path: | + /home/runner/.asdf + key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }} + restore-keys: | + ${{ runner.os }}-asdf- + - name: Install dependencies in .tool-versions + uses: asdf-vm/actions/install@v2 + - name: Install cross-compiler toolchain + run: sudo apt-get -y install gcc-aarch64-linux-gnu + - name: Run build + run: just build-all --id linux + - uses: actions/upload-artifact@v3 + if: ${{ failure() }} + with: + name: code + path: /home/runner/work/odict + darwin: + name: Build (Darwin) + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup asdf + uses: asdf-vm/actions/setup@v2 + - name: Cache asdf + id: cache-asdf + uses: actions/cache@v3 + with: + path: | + /home/runner/.asdf + key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }} + restore-keys: | + ${{ runner.os }}-asdf- + - name: Install dependencies in .tool-versions + uses: asdf-vm/actions/install@v2 + - name: Run build + run: just build-all --id darwin + - uses: actions/upload-artifact@v3 + if: ${{ failure() }} + with: + name: code + path: /home/runner/work/odict + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup asdf + uses: asdf-vm/actions/setup@v2 + - name: Cache asdf + id: cache-asdf + uses: actions/cache@v3 + with: + path: | + /home/runner/.asdf + key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }} + restore-keys: | + ${{ runner.os }}-asdf- + - name: Cache Poetry dependencies + uses: actions/cache@v3 + with: + path: | + /home/runner/.venv + key: ${{ runner.os }}-poetry-${{ hashFiles('**/python/poetry.lock') }} + restore-keys: | + ${{ runner.os }}-poetry- + - name: Install dependencies in .tool-versions + uses: asdf-vm/actions/install@v2 + - name: Run tests + env: + POETRY_VIRTUALENVS_IN_PROJECT: true + run: just test + - uses: actions/upload-artifact@v3 + if: ${{ failure() }} + with: + name: code + path: /home/runner/work/odict diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 0551cbf4..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Build & Test - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - test: - name: Test - runs-on: macos-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Setup asdf - uses: asdf-vm/actions/setup@v2 - - name: Cache asdf - id: cache-asdf - uses: actions/cache@v3 - with: - path: | - /home/runner/.asdf - key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }} - restore-keys: | - ${{ runner.os }}-asdf- - - name: Cache Poetry dependencies - uses: actions/cache@v3 - with: - path: | - /home/runner/.venv - key: ${{ runner.os }}-poetry-${{ hashFiles('**/python/poetry.lock') }} - restore-keys: | - ${{ runner.os }}-poetry- - - name: Install dependencies in .tool-versions - uses: asdf-vm/actions/install@v2 - - name: Run build - run: just build-all --snapshot - - name: Run tests - env: - POETRY_VIRTUALENVS_IN_PROJECT: true - run: just test - - uses: actions/upload-artifact@v3 - if: ${{ failure() }} - with: - name: code - path: /home/runner/work/odict diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a079f8e5..3ef64b27 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -12,29 +12,50 @@ git: - python-* - jvm-* +env: + - CGO_ENABLED=1 + builds: - - id: odict + - id: darwin + binary: odict main: ./odict.go ldflags: - -X 'github.com/TheOpenDictionary/odict/cli.version={{.Version}}' goos: - - linux - darwin - - windows - env: - - CGO_ENABLED=1 - - id: single + flags: + - -trimpath + - id: windows + binary: odict main: ./odict.go + ldflags: + - -X 'github.com/TheOpenDictionary/odict/cli.version={{.Version}}' + goos: + - windows + flags: + - -trimpath + - id: linux binary: odict + main: ./odict.go ldflags: - -X 'github.com/TheOpenDictionary/odict/cli.version={{.Version}}' - no_unique_dist_dir: true - env: - - CGO_ENABLED=1 + goos: + - linux + flags: + - -trimpath + overrides: + - goos: linux + goarch: arm64 + env: + - CC=aarch64-linux-gnu-gcc + - goos: linux + goarch: amd64 + env: + - CC=gcc archives: - builds: - - odict + - darwin brews: - name: odict diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..d2678472 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +ARG GORELEASER_CROSS_VERSION 0.21.3 + +FROM ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} AS goreleaser-cross + +RUN apt-get update -y && apt-get upgrade -y +RUN apt-get install -y pkg-config libxml2-dev libicu-dev gcc-multilib \ No newline at end of file diff --git a/justfile b/justfile index 8253b944..2f872b21 100644 --- a/justfile +++ b/justfile @@ -1,16 +1,18 @@ +GOLANG_CROSS_VERSION := "v1.21.3" + # ---------------------------------------------------------------------------- # # Global # # ---------------------------------------------------------------------------- # -@deps: xsd +@deps: asdf install > /dev/null go install golang.org/x/tools/cmd/goimports@latest -@build: deps (cli "schema") sync +@build: deps xsd (cli "schema") sync goreleaser build --id single --clean --snapshot --single-target @build-all +args="": deps (cli "schema") sync - goreleaser build --id odict --clean {{args}} + goreleaser build --snapshot --clean @schema: (go "schema") (cli "schema") (js "schema") @@ -20,7 +22,7 @@ @run +args="": go run odict.go {{args}} -@test: deps (go "test") (jvm "test") (python "test") (js "test") clean +@test: deps xsd (go "test") (jvm "test") (python "test") (js "test") clean @clean: (python "clean") (jvm "clean") (js "clean") rm -rf **/*.odict