Skip to content

Commit

Permalink
brand-new action in node.js (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgr0dzicki authored and obi1kenobi committed Feb 27, 2023
1 parent a708ddc commit 893685e
Show file tree
Hide file tree
Showing 11 changed files with 3,863 additions and 76 deletions.
63 changes: 16 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,21 @@ on:
branches:
- main

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always

jobs:
test-action:
name: Test the action
runs-on: ubuntu-latest
steps:
- name: Checkout the test repository
uses: actions/checkout@v3
with:
repository: mgr0dzicki/cargo-semver-action-ref-slice
fetch-depth: 0
persist-credentials: true
- name: Checkout the action
uses: actions/checkout@v3
with:
path: action
# Assumes that the latest published normal version of `ref_slice` smaller
# than 1.2.2 is 1.2.1.
# TODO: Change the crate version in the corresponding branch `patch_change`
# to 1.2.1 once new logic of choosing baseline is adapted. Otherwise
# if new version 1.2.2 of `ref_slice` is released, the tests might stop
# working correctly.
- name: Checkout the test with patch change and patch version bump
run: git checkout patch_change
- name: Run the action
uses: ./action/
# Assumes that the latest published normal version of `ref_slice` smaller
# than 1.2.2 exports a public function `ref_slice`.
# TODO: Change the crate version in the corresponding branch `major_change`
# to 1.2.1 once new logic of choosing baseline is adapted. Otherwise
# if new version 1.2.2 of `ref_slice` is released, the tests might stop
# working correctly.
- name: Checkout the test with major change and patch version bump
run: git checkout major_change
- name: Run the action (allowed to fail)
id: action_major
uses: ./action/
continue-on-error: true
- name: Check the action outcome
run: |
if [[ "${{ steps.action_major.outcome }}" != 'failure' ]]; then
echo "Error! The action should have failed because of the breaking change, but it has not."
exit 1
else
echo "OK! The action has failed as expected on the breaking change."
fi
name: Test the action on ubuntu-latest
uses: ./.github/workflows/test-action.yml
with:
runs-on: ubuntu-latest

test-action-windows-latest:
name: Test the action on windows-latest
uses: ./.github/workflows/test-action.yml
with:
runs-on: windows-latest

test-action-macos-latest:
name: Test the action on macos-latest
uses: ./.github/workflows/test-action.yml
with:
runs-on: macos-latest
59 changes: 59 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Test the action

on:
workflow_call:
inputs:
runs-on:
required: true
type: string

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always

jobs:
run-tests:
name: Run tests
runs-on: ${{ inputs.runs-on }}
steps:
- name: Checkout the test repository
uses: actions/checkout@v3
with:
repository: mgr0dzicki/cargo-semver-action-ref-slice
fetch-depth: 0
persist-credentials: true
- name: Checkout the action
uses: actions/checkout@v3
with:
path: action
# Assumes that the latest published normal version of `ref_slice` smaller
# than 1.2.2 is 1.2.1.
# TODO: Change the crate version in the corresponding branch `patch_change`
# to 1.2.1 once new logic of choosing baseline is adapted. Otherwise
# if new version 1.2.2 of `ref_slice` is released, the tests might stop
# working correctly.
- name: Checkout the test with patch change and patch version bump
run: git checkout patch_change
- name: Run the action
uses: ./action/
env:
GITHUB_TOKEN: ${{ github.token }}
# Assumes that the latest published normal version of `ref_slice` smaller
# than 1.2.2 exports a public function `ref_slice`.
# TODO: Change the crate version in the corresponding branch `major_change`
# to 1.2.1 once new logic of choosing baseline is adapted. Otherwise
# if new version 1.2.2 of `ref_slice` is released, the tests might stop
# working correctly.
- name: Checkout the test with major change and patch version bump
run: git checkout major_change
- name: Run the action (allowed to fail)
id: action_major
uses: ./action/
env:
GITHUB_TOKEN: ${{ github.token }}
continue-on-error: true
- name: Fail if the action has not returned any errors (but it should have)
if: steps.action_major.outcome != 'failure'
run: |
echo "Error! The action should have failed because of the breaking change, but it has not."
exit 1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.idea
.vscode
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@actions-rs:registry=https://npm.pkg.github.com
31 changes: 2 additions & 29 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,5 @@ inputs:
required: true
default: false
runs:
using: "composite"
steps:
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: Check for semver violations
shell: bash
run: |
set -euxo pipefail
# Colorize output, since GitHub Actions terminals support color.
export CARGO_TERM_COLOR=always
export CRATE_NAME="${{ inputs.crate-name }}"
export MANIFEST_PATH="${{ inputs.manifest-path }}"
if [[ ${{ inputs.verbose }} == 'true' ]]; then
export VERBOSE_FLAG="--verbose"
else
export VERBOSE_FLAG=""
fi
export SEMVER_CHECKS_OPTIONS="${CRATE_NAME:+"--package $CRATE_NAME"} ${MANIFEST_PATH:+"--manifest-path $MANIFEST_PATH"} $VERBOSE_FLAG"
# Check for semver violations.
cargo install cargo-semver-checks --locked
cargo semver-checks check-release $SEMVER_CHECKS_OPTIONS
using: 'node16'
main: 'dist/index.js'
201 changes: 201 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

Loading

0 comments on commit 893685e

Please sign in to comment.