Skip to content

Commit

Permalink
Add workflows (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
robherley authored Apr 21, 2023
1 parent f18ecf5 commit 1b3779e
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint

on:
push:

permissions:
contents: read

jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Setup libtensorflow
run: script/install-libtensorflow
- uses: golangci/golangci-lint-action@v3
with:
version: v1.52.2
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test

on:
push:

permissions:
contents: read

jobs:
gotest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Setup libtensorflow
run: script/install-libtensorflow
- name: Test
uses: robherley/[email protected]
with:
omitUntestedPackages: true
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# guesslang-go 🔍

[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://pkg.go.dev/github.com/robherley/guesslang-go)
[![Test](https://github.com/robherley/guesslang-go/actions/workflows/test.yml/badge.svg)](https://github.com/robherley/guesslang-go/actions/workflows/test.yml)

Go port of [yoeo/guesslang](https://github.com/yoeo/guesslang). Detects programming language of source code using a deep learning model.

## Setup
Expand Down
32 changes: 32 additions & 0 deletions script/install-libtensorflow
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# This script downloads and installs libtensorflow (CPU only) for the current platform.
# If you are on macOS, you can just use `brew install libtensorflow` instead.
# https://www.tensorflow.org/install/lang_c

set -e

if [ "$(go env GOARCH)" != "amd64" ]; then
echo "unsupported architecture: $ARCH"
exit 1
fi

OS=$(go env GOOS)

case "$OS" in
darwin)
brew install libtensorflow
;;
linux)
TENSORFLOW_VERSION=2.11.0
ARCHIVE_PATH=$(mktemp -d)/tensorflow.tar.gz
curl -o "$ARCHIVE_PATH" "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-${OS}-x86_64-${TENSORFLOW_VERSION}.tar.gz"
sudo tar -xzf "$ARCHIVE_PATH" -C /usr/local
sudo ldconfig /usr/local/lib
rm -rf "$ARCHIVE_PATH"
;;
*)
echo "unsupported OS: $OS"
exit 1
;;
esac

0 comments on commit 1b3779e

Please sign in to comment.