Skip to content

Commit

Permalink
feat: initial
Browse files Browse the repository at this point in the history
  • Loading branch information
ovsds committed Jul 19, 2024
1 parent 2ba5c93 commit 1095aaa
Show file tree
Hide file tree
Showing 10 changed files with 2,349 additions and 37 deletions.
35 changes: 35 additions & 0 deletions .github/actions/assert_equals/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: AssertEquals
description: Asserts that actual value equals expected value

inputs:
actual:
description: "Value to assert"
required: true

expected:
description: "Expected value"
required: true

message:
description: "Message to display if assertion fails"
required: false
default: "Assertion failed"

runs:
using: "composite"
steps:
- name: Assert
id: assert
shell: bash
run: |
actual="${{ inputs.actual }}"
expected="${{ inputs.expected }}"
message="${{ inputs.message }}"
if [[ "$actual" != "$expected" ]]; then
echo "$message. Expected: $expected, Actual: $actual"
exit 1
fi
branding:
icon: "check-circle"
color: "green"
185 changes: 185 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: E2E

on:
pull_request:
types:
- opened
- reopened
- synchronize

jobs:
e2e-default:
runs-on: ubuntu-20.04

permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Test Run
id: test-run
uses: ./
with:
owner: ovsds
repo: push-version-tags-action
tag_name: v1.0.0

- name: Assert exists
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.exists }}
expected: "true"

- name: Assert tag name
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.tag_name }}
expected: "v1.0.0"

- name: Assert tag sha
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.tag_sha }}
expected: "29ae696c9f5bdb8d25dc5dbfd3a88acb2af001f3"

- name: Assert tag type
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.tag_type }}
expected: "commit"

- name: Assert commit sha
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.commit_sha }}
expected: "29ae696c9f5bdb8d25dc5dbfd3a88acb2af001f3"

- name: Assert tag message
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.tag_message }}
expected: "feat: init (#1)"

- name: Assert verified
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.verified }}
expected: "true"

e2e-unverified-commit-type:
runs-on: ubuntu-20.04

permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Test Run
id: test-run
uses: ./
with:
tag_name: unverified_tag

- name: Assert exists
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.exists }}
expected: "true"

- name: Assert tag name
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.tag_name }}
expected: "unverified_tag"

- name: Assert tag sha
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.tag_sha }}
expected: "518c2e81cd748430d589f760efa3b0847d1e1c3d"

- name: Assert tag type
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.tag_type }}
expected: "commit"

- name: Assert commit sha
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.commit_sha }}
expected: "518c2e81cd748430d589f760efa3b0847d1e1c3d"

- name: Assert tag message
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.tag_message }}
expected: "unverified_commit"

- name: Assert verified
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.verified }}
expected: "false"

e2e-not-exists:
runs-on: ubuntu-20.04

permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Test Run
id: test-run
uses: ./
with:
tag_name: definitely-not-a-tag

- name: Assert exists
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.exists }}
expected: "false"

- name: Assert tag name
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.tag_name }}
expected: ""

- name: Assert tag sha
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.tag_sha }}
expected: ""

- name: Assert tag type
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.tag_type }}
expected: ""

- name: Assert commit sha
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.commit_sha }}
expected: ""

- name: Assert tag message
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.tag_message }}
expected: ""

- name: Assert verified
uses: ./.github/actions/assert_equals
with:
actual: ${{ steps.test-run.outputs.verified }}
expected: ""
5 changes: 0 additions & 5 deletions .husky/.huskyrc

This file was deleted.

6 changes: 1 addition & 5 deletions .husky/commit-msg
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
#!/usr/bin/env sh
. "$(dirname $0)/.huskyrc"
. "$(dirname $0)/_/husky.sh"

npx --no -- commitlint --edit
npx --no -- commitlint --edit
4 changes: 0 additions & 4 deletions .husky/pre-commit
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
#!/usr/bin/env sh
. "$(dirname $0)/.huskyrc"
. "$(dirname $0)/_/husky.sh"

npx lint-staged
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![CI](https://github.com/ovsds/get-tag-info-action/workflows/Check%20PR/badge.svg)](https://github.com/ovsds/get-tag-info-action/actions?query=workflow%3A%22%22Check+PR%22%22)
[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-Get%20Tag%20Info-blue.svg)](https://github.com/marketplace/actions/get-tag-info)

Get Tag Info Action
Gets information for a tag.

## Usage

Expand All @@ -15,15 +15,24 @@ Get Tag Info Action

### Action Inputs

| Name | Description | Default |
| ------------- | ------------ | ------- |
| `placeholder` | Placeholder. | |
| Name | Description | Default |
| -------------- | ------------------------------------------------------------------ | ----------------------------------- |
| `github_token` | Github token used for API calls. Required scope - 'contents: read' | ${{ github.token }} |
| `owner` | Repository owner. | ${{ github.repository_owner }} |
| `repo` | Repository name. | ${{ github.event.repository.name }} |
| `tag_name` | Tag name. | |

### Action Outputs

| Name | Description |
| ------------- | ------------ |
| `placeholder` | Placeholder. |
| Name | Description |
| ------------- | ------------- |
| `exists` | Tag exists. |
| `tag_name` | Tag name. |
| `tag_sha` | Tag SHA. |
| `tag_type` | Tag type. |
| `commit_sha` | Commit SHA. |
| `tag_message` | Tag message. |
| `verified` | Tag verified. |

## Development

Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ tasks:

- echo 'Installing node dependencies...'
- task: _with_nvm
vars: { COMMAND: "npm clean-install" }
vars: { COMMAND: "npm install" }

- echo 'Installing husky pre-commit...'
- task: _with_nvm
vars: { COMMAND: "npm run prepare-husky" }
vars: { COMMAND: "npm run prepare" }

lint:
desc: Lint project
Expand Down
Loading

0 comments on commit 1095aaa

Please sign in to comment.