Skip to content

Commit

Permalink
Merge pull request #13 from urfave/matrixize
Browse files Browse the repository at this point in the history
Generate matrix env entries
  • Loading branch information
brackendawson authored Oct 26, 2022
2 parents c440bef + 13cdf4b commit 2265ff7
Show file tree
Hide file tree
Showing 24 changed files with 454 additions and 949 deletions.
129 changes: 86 additions & 43 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,107 @@ env:
SHELLCHECK_URL: "https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.x86_64.tar.xz"
SHFMT_URL: "https://github.com/mvdan/sh/releases/download/v3.5.1/shfmt_v3.5.1_linux_amd64"
jobs:
build:
prebuild:
strategy:
matrix:
env:
- runner: ubuntu-latest
goos: linux
goarch: amd64
target: native
# - runner: ubuntu-latest
# goos: linux
# goarch: arm64
# target: arm64
- runner: macos-latest
goos: darwin
goarch: amd64
target: native
# - runner: macos-latest
# goos: darwin
# goarch: arm64
# target: arm64
runner: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v3
- if: runner.os == 'macOS'
uses: actions/cache@v3
with:
path: |
~/.gimme
~/go/pkg/mod
~/Library/Caches/go-build
key: "${{ runner.os }}-prebuild-${{ hashFiles('go.sum') }}"
restore-keys: |
${{ runner.os }}-prebuild-
- if: runner.os == 'Linux'
uses: actions/cache@v3
with:
path: |
~/.gimme
~/go/pkg/mod
~/.cache/go-build
key: "${{ runner.os }}-prebuild-${{ hashFiles('go.sum') }}"
restore-keys: |
${{ runner.os }}-prebuild-
- run: ./gimme module | grep ^export | tee -a "${GITHUB_ENV}"
- run: make gimme-generate
- uses: actions/upload-artifact@v3
with:
name: gimme-generate-${{ runner.os }}
path: gimme-generate
matrix:
name: matrix
needs: [prebuild]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: gimme-generate-${{ runner.os }}
- run: chmod -v +x gimme-generate
- id: env
run: make matrix
- run: make assert-no-diff
outputs:
env: ${{ steps.env.outputs.env }}
test:
needs: [matrix]
strategy:
matrix:
env: ${{ fromJson(needs.matrix.outputs.env) }}
runs-on: ${{ matrix.env.runner }}
env:
TARGET: ${{ matrix.env.target }}
GOOS: ${{ matrix.env.goos }}
GOARCH: ${{ matrix.env.goarch }}
GIMME_MODULE_PREFIX: .testdata/
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- if: runner.os == 'macOS'
uses: actions/cache@v3
with:
path: ${HOME}/.gimme
key: "${{ runner.os }}-${{ matrix.env.target }}-gimme-${{ hashFiles('.testdata/*-${{ matrix.env.goos }}') }}"
path: ~/.gimme
key: "${{ runner.os }}-${{ matrix.env.target }}-${{ matrix.env.version }}-test-${{ hashFiles('.testdata/sample-binary-*') }}"
restore-keys: |
${{ runner.os }}-${{ matrix.env.target }}-gimme-
- run: printf 'GIMME_TMP=%s\n' "${RUNNER_TEMP}" | tee -a "${GITHUB_ENV}"
- run: printf 'UNAME=%s\n' "$(uname | tr '[:upper:]' '[:lower:]')" | tee -a "${GITHUB_ENV}"
- run: |
GO_VERSIONS="$(sed -n -e '/^[^#]/p' < .testdata/sample-binary-$UNAME) $(sed -n -e '/^[^#]/p' < .testdata/source-$UNAME)";
printf 'GO_VERSIONS=%s\n' "$(echo "${GO_VERSIONS}" | tr '\n' ' ')" | tee -a "${GITHUB_ENV}";
- run: printf 'PATH=%s\n' "${HOME}/bin:${PATH}" | tee -a "${GITHUB_ENV}"
- run: mkdir -p "${HOME}/bin"
${{ runner.os }}-${{ matrix.env.target }}-${{ matrix.env.version }}-test-
${{ runner.os }}-${{ matrix.env.target }}-
- if: runner.os == 'Linux'
uses: actions/cache@v3
with:
path: ~/.gimme
key: "${{ runner.os }}-${{ matrix.env.target }}-${{ matrix.env.version }}-test-${{ hashFiles('.testdata/sample-binary-*') }}"
restore-keys: |
${{ runner.os }}-${{ matrix.env.target }}-${{ matrix.env.version }}-test-
${{ runner.os }}-${{ matrix.env.target }}-
- uses: actions/download-artifact@v3
with:
name: gimme-generate-${{ runner.os }}
- run: |
if [ $UNAME = linux ] && [[ $(shellcheck --version | awk '/^version:/ { print $2 }') != 0.7.1 ]] ; then
chmod -v +x gimme-generate
printf 'GIMME_TMP=%s\n' "${RUNNER_TEMP}" | tee -a "${GITHUB_ENV}"
printf 'PATH=%s\n' "${HOME}/bin:${PATH}" | tee -a "${GITHUB_ENV}"
mkdir -p ~/bin
- name: ensure shell linting tools
if: runner.os == 'Linux'
run: |
if [[ $(shellcheck --version | awk '/^version:/ { print $2 }') != 0.7.1 ]] ; then
curl -sSL -o "${GIMME_TMP}/shellcheck.tar.xz" "${SHELLCHECK_URL}";
tar -C "${HOME}/bin" --exclude="*.txt" --strip-components=1 -xf "${GIMME_TMP}/shellcheck.tar.xz";
tar -C ~/bin --exclude="*.txt" --strip-components=1 -xf "${GIMME_TMP}/shellcheck.tar.xz";
shellcheck --version;
fi
- run: |
if [ $UNAME = linux ] && [[ $(shfmt -version 2>/dev/null) != v3.5.1 ]] ; then
curl -sSL "${SHFMT_URL}" -o "${HOME}/bin/shfmt";
chmod +x "${HOME}/bin/shfmt";
fi;
if [[ $(shfmt -version 2>/dev/null) != v3.5.1 ]] ; then
curl -sSL "${SHFMT_URL}" -o ~/bin/shfmt;
chmod +x ~/bin/shfmt;
shfmt -version;
fi
- run: if [ $UNAME = linux ]; then make lint; fi
- run: git diff --exit-code
- run: git diff --cached --exit-code
- if: runner.os == 'Linux'
run: make lint
- run: make assert-no-diff
- run: ./gimme -h
- run: ./gimme -V
- run: ./gimme -l
- run: ./runtests "${TARGET}" "${GO_BOOTSTRAP_VERSION}" ${GO_VERSIONS}
- run: ./runtests "${TARGET}" "${GO_BOOTSTRAP_VERSION}" '${{ matrix.env.version }}'
- run: ./gimme -l
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.testdata/object-urls
/.testdata/known-versions.txt
/gimme-generate
240 changes: 0 additions & 240 deletions .testdata/binary-darwin

This file was deleted.

Loading

0 comments on commit 2265ff7

Please sign in to comment.