Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 of the action #21

Merged
merged 24 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c84e648
Use baseline choosing logic of cargo-semver-checks
mgr0dzicki Jan 3, 2023
e190793
Remove unused options
mgr0dzicki Jan 3, 2023
d806583
Update scenario description in README
mgr0dzicki Jan 3, 2023
1235a56
Add manifest-path option
mgr0dzicki Jan 3, 2023
d907cbb
Add verbose option
mgr0dzicki Jan 3, 2023
fb6f709
brand-new action in node.js (#4)
mgr0dzicki Jan 8, 2023
93886bb
Add ending newlines
mgr0dzicki Feb 20, 2023
eef3fdc
Typos in README.md
mgr0dzicki Feb 21, 2023
bf8c967
Add dist/ check to CI (#8)
mgr0dzicki Feb 21, 2023
851a833
[TEMP-FIX] Add creating index directory on Windows (#9)
mgr0dzicki Feb 21, 2023
4c5045c
Add eslint and prettier (#10)
mgr0dzicki Feb 22, 2023
2d4767c
[TEMP-FIX] Fix mkdir failing if index already exists (#11)
mgr0dzicki Feb 22, 2023
3b1fbc1
Rename crate-name to package
mgr0dzicki Feb 22, 2023
070ca6e
Add github-token input (#13)
mgr0dzicki Feb 23, 2023
f438b41
Use matrix strategy in CI
mgr0dzicki Feb 23, 2023
ba2d119
Proper error handling
mgr0dzicki Feb 24, 2023
e8b859b
Tests and fixes for inputs (#14)
mgr0dzicki Feb 25, 2023
551e9e6
Explain user and email in npm-cli-login (#15)
mgr0dzicki Feb 26, 2023
d4f64c4
Work on README
mgr0dzicki Feb 26, 2023
95ed10f
Update README.md
mgr0dzicki Feb 27, 2023
9a34105
CI improvements (#17)
mgr0dzicki Feb 27, 2023
c98f915
Env variables in ci.yml
mgr0dzicki Feb 27, 2023
f6f51dd
Minor fixes in inputs specifications
mgr0dzicki Feb 27, 2023
f8d48b6
Get rid of fetch-depth: 0 in test-manifest-path-with-space
mgr0dzicki Feb 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
root: true,
rules: {
'curly': 'error'
}
};
9 changes: 9 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The testing workflow is divided into three parts:
- `test-build.yml` is run on `ubuntu-latest` and contains source-related checks:
linters, formatters and verifying whether the sources match dist/ directory.
- `test-action.yml` contains simple, general integration tests of the action
that should be run on each platform.
- `test-inputs.yml` is run on `ubuntu-latest` and contains specific integration
tests checking whether the action inputs are processed properly.

`setup-test-workspace` is a helper action that creates a workspace containing two crates: the test fork of `ref_slice` and a dummy crate that has no matching baseline version on `crates.io`.
62 changes: 15 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,20 @@ on:
branches:
- main

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always

mgr0dzicki marked this conversation as resolved.
Show resolved Hide resolved
jobs:
mgr0dzicki marked this conversation as resolved.
Show resolved Hide resolved
test-build:
name: Test build
uses: ./.github/workflows/test-build.yml

obi1kenobi marked this conversation as resolved.
Show resolved Hide resolved
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: Smoke test the action
uses: ./.github/workflows/test-action.yml
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
with:
runs-on: ${{ matrix.os }}

test-inputs:
name: Test action inputs
uses: ./.github/workflows/test-inputs.yml
24 changes: 24 additions & 0 deletions .github/workflows/setup-test-workspace/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Setup test workspace
inputs:
ref-slice-ref:
description: 'Reference of the ref_slice to checkout'
mgr0dzicki marked this conversation as resolved.
Show resolved Hide resolved
required: false
default: ''
mgr0dzicki marked this conversation as resolved.
Show resolved Hide resolved
runs:
using: 'composite'
steps:
- name: Checkout the ref-slice fork
uses: actions/checkout@v3
with:
repository: mgr0dzicki/cargo-semver-action-ref-slice
ref: ${{ inputs.ref-slice-ref }}
persist-credentials: true
path: ref_slice
- name: Create dummy crate
# This crate does not have a matching baseline on crates.io, so any try
# of checking it should make cargo-semver-checks fail.
run: cargo new cargo-semver-action-dummy --lib
shell: bash
- name: Create workspace Cargo.toml
run: echo -e "[workspace]\nmembers=['ref_slice','cargo-semver-action-dummy']" > Cargo.toml
shell: bash
50 changes: 50 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Smoke test the action
obi1kenobi marked this conversation as resolved.
Show resolved Hide resolved

# 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 branches `patch_change`
# and `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.

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 and test with patch change and patch version bump
uses: actions/checkout@v3
with:
repository: mgr0dzicki/cargo-semver-action-ref-slice
ref: patch_change
persist-credentials: true
- name: Checkout the action
uses: actions/checkout@v3
with:
path: action
- name: Run the action
uses: ./action/
- name: Checkout the test with major change and patch version bump
run: |
git fetch origin major_change
git checkout major_change
- name: Run the action (allowed to fail)
id: action_major
uses: ./action/
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
54 changes: 54 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test action build

on:
workflow_call:

jobs:
test-build:
name: Check if the source files build successfully and match dist/ directory
runs-on: ubuntu-latest
steps:
- name: Checkout the action
uses: actions/checkout@v3
- name: Setup Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install npm-cli-login
run: npm install -g npm-cli-login
- name: Login to GitHub npm registry
# Both username and email address are irrelevant here, but they must be
# specified because otherwise npm-cli-login fails.
run: |
npm-cli-login -s @actions-rs -r https://npm.pkg.github.com \
-u does_not_matter -p ${{ secrets.GITHUB_TOKEN }} -e does_not_m@ter.com
- name: Install dependencies
run: npm ci
- name: Rebuild the action
run: npm run all
- name: Compare the expected and actual src/ directories
run: |
if [ "$(git diff src/ | wc -l)" -gt "0" ]; then
echo "Source files are not properly formatted!"
exit 1
fi
id: diff_src
- name: Upload the expected version of src/ in case of failure
uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff_src.conclusion == 'failure' }}
with:
name: expected-src
path: src/
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff dist/ | wc -l)" -gt "0" ]; then
echo "Built sources do not match the content of the dist/ directory!"
exit 1
fi
id: diff_dist
- name: Upload the expected version of dist/ in case of failure
uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff_dist.conclusion == 'failure' }}
with:
name: expected-dist
path: dist/
Loading