From fc3e48b8a56811dadea421849823eee7d808a083 Mon Sep 17 00:00:00 2001 From: James Hegedus Date: Thu, 9 Mar 2023 13:09:07 +0000 Subject: [PATCH] ci: automate releases with release-please (#519)Co-authored-by: jthegedus <41898282+github-actions[bot]@users.noreply.github.com> * wip: wip * docs: undo readme updates * ci: enforce semantic PRs via GitHub Actions (#2) * ci: release please tag major versions for actions (#4) Co-authored-by: jthegedus <41898282+github-actions[bot]@users.noreply.github.com> * ci: build workflow trigger to only run on PR or push not both * ci: separate build & test workflows * ci: fix missing id on release-please step * ci: fix references to workflow defaults in tests * ci: fix test workflow os strategy matrix * ci: format * ci: fix test workflow os strategy matrix * ci: fix deprecated github action commands in build workflow * ci: fix deprecated github action commands in lint workflow * ci: fix shellcheck errors in test workflow run cmd --------- Co-authored-by: jthegedus <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 52 ++++++++ .github/workflows/codeql.yml | 2 +- .github/workflows/lint.yaml | 64 ++++++++++ .github/workflows/release.yaml | 33 +++++ .github/workflows/semantic-pr.yaml | 18 +++ .github/workflows/test.yml | 98 +++++++++++++++ .github/workflows/workflow.yml | 186 ----------------------------- .tool-versions | 3 +- CHANGELOG.md | 4 - package.json | 2 +- 10 files changed, 269 insertions(+), 193 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/lint.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/semantic-pr.yaml create mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..cbdfb10a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,52 @@ +name: build + +on: + push: + branches: + - master + pull_request: + +jobs: + build: + strategy: + fail-fast: false + matrix: + os: + - macos-latest + - ubuntu-latest + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Use Node.js 16.x + uses: actions/setup-node@v3 + with: + node-version: 16.x + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT" + - name: Retrieve yarn cache + uses: actions/cache@v3 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: v1-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} + restore-keys: | + v1-${{ runner.os }}-yarn- + + - name: Install npm packages + run: yarn --frozen-lockfile + + - name: Ensure out directories are up-to-date + if: runner.os == 'Linux' + shell: bash + run: | + yarn build + if [ "$(git status --porcelain | wc -l)" -gt "0" ]; then + echo "Detected uncommitted changes after build. See status below:" + git diff + exit 1 + fi diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a9039e54..b2ef62f5 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,4 +1,4 @@ -name: CodeQL +name: codeql on: - pull_request diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..de1a11f6 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,64 @@ +name: lint + +on: + push: + branches: + - master + pull_request: + +jobs: + eslint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16.x + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT" + - name: Install npm packages + run: yarn --frozen-lockfile + - name: Check lint + run: yarn lint + + prettier: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16.x + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT" + - name: Install npm packages + run: yarn --frozen-lockfile + - name: Check formatting + run: yarn fmt:check + + typecheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16.x + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT" + - name: Install npm packages + run: yarn --frozen-lockfile + - name: Check types + run: yarn typecheck + + actionlint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Check workflow files + uses: docker://rhysd/actionlint:1.6.23 + with: + args: -color diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..3cafbcf5 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,33 @@ +name: release + +on: + push: + branches: + - master + +permissions: + contents: write + pull-requests: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + release-type: node + command: github-release + # extra-files: | + # README.md + - uses: actions/checkout@v2 + - name: tag major versions + if: ${{ steps.release.outputs.release_created }} + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git" + git tag -d v${{ steps.release.outputs.major }} || true + git push origin :v${{ steps.release.outputs.major }} || true + git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }}" + git push origin v${{ steps.release.outputs.major }} diff --git a/.github/workflows/semantic-pr.yaml b/.github/workflows/semantic-pr.yaml new file mode 100644 index 00000000..c1352656 --- /dev/null +++ b/.github/workflows/semantic-pr.yaml @@ -0,0 +1,18 @@ +name: lint + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + semantic-pr: + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5.1.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + validateSingleCommit: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..d3841c14 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,98 @@ +name: test + +on: + push: + branches: + - master + pull_request: + +jobs: + asdf_is_installed: + strategy: + fail-fast: false + matrix: + os: ["macos-latest", "ubuntu-latest"] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: setup asdf + uses: ./setup + - name: asdf is available + run: | + echo ASDF_DIR="${ASDF_DIR}" + echo ASDF_DATA_DIR="${ASDF_DATA_DIR}" + echo PATH="${PATH}" + asdf --version + + plugin_is_tested: + strategy: + fail-fast: false + matrix: + os: ["macos-latest", "ubuntu-latest"] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: ./plugin-test + with: + command: direnv --version + plugin: direnv + giturl: https://github.com/asdf-community/asdf-direnv.git + gitref: master + + plugins_are_installed: + strategy: + fail-fast: false + matrix: + os: ["macos-latest", "ubuntu-latest"] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: ./plugins-add + with: + tool_versions: | + # tools won't be installed by this action, only plugins + elixir foo + nodejs bar + - run: | + asdf plugin list --urls --refs | grep elixir + asdf plugin list --urls --refs | grep nodejs + + installing-plugins-already-installed-are-skiped: + strategy: + fail-fast: false + matrix: + os: ["macos-latest", "ubuntu-latest"] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: ./setup + - name: Add an asdf plugin + run: | + asdf plugin-add clusterctl https://github.com/pfnet-research/asdf-clusterctl.git + - uses: ./plugins-add + with: + tool_versions: | + # tools won't be installed by this action, only plugins + elixir foo + nodejs bar + # plugins already installed are here + clusterctl tako + - run: | + asdf plugin list --urls --refs | grep elixir + asdf plugin list --urls --refs | grep nodejs + asdf plugin list --urls --refs | grep clusterctl + + tools_are_installed: + strategy: + fail-fast: false + matrix: + os: ["macos-latest", "ubuntu-latest"] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: setup asdf + uses: ./install + with: + before_install: echo asdf nodejs import-keyring + tool_versions: direnv 2.32.1 + - run: direnv version diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml deleted file mode 100644 index 13c3103e..00000000 --- a/.github/workflows/workflow.yml +++ /dev/null @@ -1,186 +0,0 @@ -name: Main workflow - -on: - - pull_request - - push - -jobs: - build: - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Use Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - - name: Retrieve yarn cache - uses: actions/cache@v3 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: v1-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} - restore-keys: | - v1-${{ runner.os }}-yarn- - - - name: Install npm packages - run: yarn --frozen-lockfile - - - name: Check formatting - run: yarn fmt:check - - - name: Check lint - run: yarn lint - - - name: Check type - run: yarn typecheck - - - name: Ensure out directories are up-to-date - if: runner.os == 'Linux' - shell: bash - run: | - yarn build - if [ "$(git status --porcelain | wc -l)" -gt "0" ]; then - echo "Detected uncommitted changes after build. See status below:" - git diff - exit 1 - fi - - asdf_is_installed: - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: setup asdf - uses: ./setup - - - name: asdf is available - run: | - echo ASDF_DIR=$ASDF_DIR - echo ASDF_DATA_DIR=$ASDF_DATA_DIR - echo PATH=$PATH - asdf --version - - plugin_is_tested: - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - uses: ./plugin-test - with: - command: direnv --version - plugin: direnv - giturl: https://github.com/asdf-community/asdf-direnv.git - gitref: master - - plugins_are_installed: - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - uses: ./plugins-add - with: - tool_versions: | - # tools won't be installed by this action, only plugins - elixir foo - nodejs bar - - - run: | - asdf plugin list --urls --refs | grep elixir - asdf plugin list --urls --refs | grep nodejs - - installing-plugins-already-installed-are-skiped: - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - uses: ./setup - - - name: Add an asdf plugin - run: | - asdf plugin-add clusterctl https://github.com/pfnet-research/asdf-clusterctl.git - - - uses: ./plugins-add - with: - tool_versions: | - # tools won't be installed by this action, only plugins - elixir foo - nodejs bar - # plugins already installed are here - clusterctl tako - - - run: | - asdf plugin list --urls --refs | grep elixir - asdf plugin list --urls --refs | grep nodejs - asdf plugin list --urls --refs | grep clusterctl - - tools_are_installed: - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: setup asdf - uses: ./install - with: - before_install: echo asdf nodejs import-keyring - tool_versions: direnv 2.32.1 - - - run: direnv version diff --git a/.tool-versions b/.tool-versions index ffd2870b..01dd94a6 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1,2 @@ -nodejs 16.18.0 +nodejs 16.19.1 +yarn 1.22.19 diff --git a/CHANGELOG.md b/CHANGELOG.md index f2e5e042..4fa419b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,6 @@ All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to -[Semantic Versioning](https://semver.org/spec/v2.0.0.html). - ## [1.1.0] - 2020-12-22 ### Added diff --git a/package.json b/package.json index c8d37df8..596d374b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@asdf-vm/actions", - "version": "1.0.1", + "version": "1.1.0", "description": "asdf github actions", "repository": "https://github.com/asdf-vm/actions", "author": "Victor Borja ",