Merge pull request #33 from zenodeapp/genesis-v1.0.0 #56
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
- release/** | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: cachix/install-nix-action@v22 | |
with: | |
# pin to nix-2.13 to workaround compability issue of 2.14, | |
# see: https://github.com/cachix/install-nix-action/issues/161 | |
install_url: https://releases.nixos.org/nix/nix-2.13.3/install | |
nix_path: nixpkgs=channel:nixos-22.11 | |
extra_nix_config: | | |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
- id: changed-files | |
uses: tj-actions/changed-files@v34 | |
with: | |
files: | | |
**/*.go | |
*.mod | |
*.sum | |
- uses: cachix/cachix-action@v12 | |
if: steps.changed-files.outputs.any_changed == 'true' | |
with: | |
name: cronos | |
# github don't pass secrets for pull request from fork repos, | |
# in that case the push is disabled naturally. | |
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}" | |
- name: Run build | |
run: ./scripts/release.sh | |
if: steps.changed-files.outputs.any_changed == 'true' | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: "genesisd-tarball-${{ matrix.os }}" | |
path: "*.tar.gz" | |
if-no-files-found: ignore | |
unittest: | |
runs-on: ubuntu-latest | |
timeout-minutes: 40 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: cachix/install-nix-action@v22 | |
with: | |
# pin to nix-2.13 to workaround compability issue of 2.14, | |
# see: https://github.com/cachix/install-nix-action/issues/161 | |
install_url: https://releases.nixos.org/nix/nix-2.13.3/install | |
nix_path: nixpkgs=channel:nixos-22.11 | |
extra_nix_config: | | |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: "^1.20.0" | |
- id: changed-files | |
uses: tj-actions/changed-files@v34 | |
with: | |
files: | | |
**/*.go | |
*.mod | |
*.sum | |
- name: test & coverage report creation | |
run: | | |
make test | |
if: steps.changed-files.outputs.any_changed == 'true' | |
- name: filter out proto files | |
run: | | |
excludelist+=" $(find ./ -type f -name '*.pb.go')" | |
for filename in ${excludelist}; do | |
filename=$(echo $filename | sed 's/^./github.com\/crypto-org-chain\/cronos/g') | |
echo "Excluding ${filename} from coverage report..." | |
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt | |
done | |
if: steps.changed-files.outputs.any_changed == 'true' | |
- uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./coverage.txt | |
fail_ci_if_error: true | |
if: steps.changed-files.outputs.any_changed == 'true' | |
gomod2nix: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- id: changed-files | |
uses: tj-actions/changed-files@v34 | |
with: | |
files: | | |
go.mod | |
go.sum | |
- uses: cachix/install-nix-action@v22 | |
with: | |
# pin to nix-2.13 to workaround compability issue of 2.14, | |
# see: https://github.com/cachix/install-nix-action/issues/161 | |
install_url: https://releases.nixos.org/nix/nix-2.13.3/install | |
nix_path: nixpkgs=channel:nixos-22.11 | |
extra_nix_config: | | |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
if: steps.changed-files.outputs.any_changed == 'true' | |
- name: gomod2nix | |
run: nix run -f ./nix gomod2nix | |
if: steps.changed-files.outputs.any_changed == 'true' | |
- name: check working directory is clean | |
id: changes | |
run: | | |
set +e | |
(git diff --no-ext-diff --exit-code) | |
echo "name=changed::$?" >> $GITHUB_OUTPUT | |
- uses: actions/upload-artifact@v3 | |
if: steps.changes.outputs.changed == 1 | |
with: | |
name: gomod2nix.toml | |
path: ./gomod2nix.toml | |
- if: steps.changes.outputs.changed == 1 | |
run: echo "Working directory is dirty" && exit 1 | |
contracts: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- id: changed-files | |
uses: tj-actions/changed-files@v34 | |
with: | |
files: | | |
contracts | |
- uses: cachix/install-nix-action@v22 | |
with: | |
# pin to nix-2.13 to workaround compability issue of 2.14, | |
# see: https://github.com/cachix/install-nix-action/issues/161 | |
install_url: https://releases.nixos.org/nix/nix-2.13.3/install | |
nix_path: nixpkgs=channel:nixos-22.11 | |
extra_nix_config: | | |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
if: steps.changed-files.outputs.any_changed == 'true' | |
- uses: cachix/cachix-action@v12 | |
if: steps.changed-files.outputs.any_changed == 'true' | |
with: | |
name: cronos | |
extraPullNames: dapp | |
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}" | |
- name: test contracts | |
if: steps.changed-files.outputs.any_changed == 'true' | |
run: make test-cronos-contracts | |
- name: build contracts | |
if: steps.changed-files.outputs.any_changed == 'true' | |
run: make gen-cronos-contracts | |
- name: check working directory is clean | |
id: changes | |
run: | | |
set +e | |
(git diff --no-ext-diff --exit-code) | |
echo "name=changed::$?" >> $GITHUB_OUTPUT | |
- uses: actions/upload-artifact@v3 | |
if: steps.changes.outputs.changed == 1 | |
with: | |
name: contracts_out | |
path: ./contracts/out | |
if-no-files-found: ignore | |
- if: steps.changes.outputs.changed == 1 | |
run: echo "Working directory is dirty" && exit 1 |