mirror of
https://github.com/GoTestTools/gotestfmt-action.git
synced 2026-02-08 16:57:30 +00:00
Compare commits
No commits in common. "main" and "v2.1.0" have entirely different histories.
3 changed files with 49 additions and 51 deletions
52
.github/workflows/selftest.yml
vendored
52
.github/workflows/selftest.yml
vendored
|
|
@ -1,42 +1,52 @@
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
name: Self-test
|
name: Self-test
|
||||||
jobs:
|
jobs:
|
||||||
|
self-test-ubuntu:
|
||||||
self-test:
|
name: on Ubuntu
|
||||||
strategy:
|
runs-on: ubuntu-latest
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: ['ubuntu', 'macos', 'windows']
|
|
||||||
|
|
||||||
name: on ${{ matrix.os }}
|
|
||||||
runs-on: ${{ matrix.os }}-latest
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.16
|
go-version: 1.16
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install gotestfmt
|
- name: Install gotestfmt
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GH_TOKEN }}
|
||||||
|
|
||||||
- name: Run gotestfmt
|
- name: Run gotestfmt
|
||||||
working-directory: testdata
|
working-directory: testdata
|
||||||
shell: bash
|
run: go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
|
||||||
run: |
|
|
||||||
go test -json -v ./... 2>&1 | tee gotest.${{ matrix.os }}.log | gotestfmt
|
|
||||||
|
|
||||||
- name: Upload test log
|
- name: Upload test log
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
name: test-log-${{ matrix.os }}
|
name: test-log-ubuntu
|
||||||
path: testdata/gotest.${{ matrix.os }}.log
|
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
|
if-no-files-found: error
|
||||||
|
|
@ -21,5 +21,5 @@ inputs:
|
||||||
required: false
|
required: false
|
||||||
default: 'gotestfmt'
|
default: 'gotestfmt'
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node16'
|
||||||
main: 'index.js'
|
main: 'index.js'
|
||||||
|
|
|
||||||
46
index.js
46
index.js
|
|
@ -4,40 +4,36 @@ const fs = require("fs")
|
||||||
const { execSync } = require("child_process")
|
const { execSync } = require("child_process")
|
||||||
|
|
||||||
async function downloadRelease(octokit, os, org, repo, release, token) {
|
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({
|
const releaseAssets = await octokit.rest.repos.listReleaseAssets({
|
||||||
owner: org,
|
owner: org,
|
||||||
repo: repo,
|
repo: repo,
|
||||||
release_id: release.id,
|
release_id: release.id,
|
||||||
})
|
})
|
||||||
|
tarPostfix = `_${os}_amd64.tar.gz`
|
||||||
for (let asset of releaseAssets.data) {
|
for (let asset of releaseAssets.data) {
|
||||||
console.log("Examining release asset " + asset.name + " at " + asset.browser_download_url + " ...")
|
console.log("Examining release asset " + asset.name + " at " + asset.browser_download_url + " ...")
|
||||||
if (asset.name.endsWith(postfix)) {
|
if (asset.name.endsWith(tarPostfix)) {
|
||||||
console.log("Found binary named " + asset.name + " at " + asset.browser_download_url + " , attempting download...")
|
console.log("Found Linux binary named " + asset.name + " at " + asset.browser_download_url + " , attempting download...")
|
||||||
if (token) {
|
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 {
|
} else {
|
||||||
execSync(`curl -L -o ${archive} ${asset.browser_download_url}`)
|
execSync("curl -L -o /tmp/gotestfmt.tar.gz " + asset.browser_download_url)
|
||||||
}
|
}
|
||||||
|
console.log("Creating /usr/local/lib/gotestfmt directory...")
|
||||||
console.log("Unpacking archive file...")
|
execSync("sudo mkdir -p /usr/local/lib/gotestfmt")
|
||||||
core.addPath(process.env.GITHUB_WORKSPACE)
|
console.log("Unpacking tar file...")
|
||||||
process.chdir(process.env.GITHUB_WORKSPACE)
|
execSync("cd /usr/local/lib/gotestfmt && sudo tar -xvzf /tmp/gotestfmt.tar.gz")
|
||||||
execSync(`${extract} "${archive}"`)
|
console.log("Removing tarball...")
|
||||||
|
fs.unlinkSync("/tmp/gotestfmt.tar.gz")
|
||||||
console.log("Removing asset archive...")
|
console.log("Creating /usr/local/bin directory if it does not exist already...")
|
||||||
fs.unlinkSync(archive)
|
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.")
|
console.log("Successfully set up gotestfmt.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
throw `No release asset matched postfix '${tarPostfix}'.`
|
||||||
throw `No release asset matched postfix '${postfix}'.`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadGofmt(octokit, version, versionPrefix, os, org, repo, token) {
|
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() {
|
async function determineOS() {
|
||||||
const uname = execSync("uname")
|
const os = execSync("uname").toString().trim().toLowerCase()
|
||||||
|
|
||||||
let os = uname.toString().trim().toLowerCase()
|
|
||||||
if (os.indexOf("msys_nt") === 0)
|
|
||||||
{
|
|
||||||
os = "windows";
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Running on OS '${os}'`)
|
console.log(`Running on OS '${os}'`)
|
||||||
|
|
||||||
return os
|
return os
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue