Compare commits

..

No commits in common. "main" and "v2.1.0" have entirely different histories.
main ... v2.1.0

3 changed files with 49 additions and 51 deletions

View file

@ -1,42 +1,52 @@
on:
pull_request:
name: Self-test
jobs:
self-test:
strategy:
fail-fast: false
matrix:
os: ['ubuntu', 'macos', 'windows']
name: on ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
self-test-ubuntu:
name: on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Checkout
uses: actions/checkout@v2
- name: Install gotestfmt
uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GH_TOKEN }}
- name: Run gotestfmt
working-directory: testdata
shell: bash
run: |
go test -json -v ./... 2>&1 | tee gotest.${{ matrix.os }}.log | gotestfmt
run: go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Upload test log
uses: actions/upload-artifact@v3
if: always()
with:
name: test-log-${{ matrix.os }}
path: testdata/gotest.${{ matrix.os }}.log
name: test-log-ubuntu
path: /tmp/gotest.log
if-no-files-found: error
self-test-macos:
name: on MacOS
runs-on: macos-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Checkout
uses: actions/checkout@v2
- name: Install gotestfmt
uses: ./
with:
token: ${{ secrets.GH_TOKEN }}
- name: Run gotestfmt
working-directory: testdata
run: go test -json -v ./... 2>&1 | tee ./gotest.log | gotestfmt
- name: Upload test log
uses: actions/upload-artifact@v3
if: always()
with:
name: test-log-macos
path: ./testdata/gotest.log
if-no-files-found: error

View file

@ -21,5 +21,5 @@ inputs:
required: false
default: 'gotestfmt'
runs:
using: 'node20'
using: 'node16'
main: 'index.js'

View file

@ -4,40 +4,36 @@ const fs = require("fs")
const { execSync } = require("child_process")
async function downloadRelease(octokit, os, org, repo, release, token) {
const postfix = `_${os}_amd64.${os === "windows" ? "zip" : "tar.gz"}`;
const tempdir = os === "windows" ? process.env.TEMP + "\\" : "/tmp/";
const extract = os === "windows" ? "tar -xvf" : "tar -xvzf";
const archive = `${tempdir}gotestfmt${postfix}`;
const releaseAssets = await octokit.rest.repos.listReleaseAssets({
owner: org,
repo: repo,
release_id: release.id,
})
tarPostfix = `_${os}_amd64.tar.gz`
for (let asset of releaseAssets.data) {
console.log("Examining release asset " + asset.name + " at " + asset.browser_download_url + " ...")
if (asset.name.endsWith(postfix)) {
console.log("Found binary named " + asset.name + " at " + asset.browser_download_url + " , attempting download...")
if (asset.name.endsWith(tarPostfix)) {
console.log("Found Linux binary named " + asset.name + " at " + asset.browser_download_url + " , attempting download...")
if (token) {
execSync(`curl -L -o ${archive} -H "Authorization: Bearer ${token}" ${asset.browser_download_url}`)
execSync("curl -L -o /tmp/gotestfmt.tar.gz -H \"Authorization: Bearer " + token + "\" " + asset.browser_download_url)
} else {
execSync(`curl -L -o ${archive} ${asset.browser_download_url}`)
execSync("curl -L -o /tmp/gotestfmt.tar.gz " + asset.browser_download_url)
}
console.log("Unpacking archive file...")
core.addPath(process.env.GITHUB_WORKSPACE)
process.chdir(process.env.GITHUB_WORKSPACE)
execSync(`${extract} "${archive}"`)
console.log("Removing asset archive...")
fs.unlinkSync(archive)
console.log("Creating /usr/local/lib/gotestfmt directory...")
execSync("sudo mkdir -p /usr/local/lib/gotestfmt")
console.log("Unpacking tar file...")
execSync("cd /usr/local/lib/gotestfmt && sudo tar -xvzf /tmp/gotestfmt.tar.gz")
console.log("Removing tarball...")
fs.unlinkSync("/tmp/gotestfmt.tar.gz")
console.log("Creating /usr/local/bin directory if it does not exist already...")
execSync("sudo mkdir -p /usr/local/bin")
console.log("Linking gotestfmt...")
execSync("sudo ln -s /usr/local/lib/gotestfmt/gotestfmt /usr/local/bin/gotestfmt")
console.log("Successfully set up gotestfmt.")
return
}
}
throw `No release asset matched postfix '${postfix}'.`
throw `No release asset matched postfix '${tarPostfix}'.`
}
async function downloadGofmt(octokit, version, versionPrefix, os, org, repo, token) {
@ -77,16 +73,8 @@ async function downloadGofmt(octokit, version, versionPrefix, os, org, repo, tok
}
async function determineOS() {
const uname = execSync("uname")
let os = uname.toString().trim().toLowerCase()
if (os.indexOf("msys_nt") === 0)
{
os = "windows";
}
const os = execSync("uname").toString().trim().toLowerCase()
console.log(`Running on OS '${os}'`)
return os
}