Skip to content

Commit

Permalink
Introduce version 2 (#2)
Browse files Browse the repository at this point in the history
* Add action schema

* Add npm-package test project

* Add rust-crate test project

* Introduce rust-wasm test project

* Delete single-step pipeline

* Remove obsolete workflow

* Introduce check-rust-versions

* Introduce install-wasm-pack

* Introduce detect-project-tech

* Introduce detect-branch-version

* Introduce inject-branch-version and check-artifact-version

* Introduce check-action-references

* Introduce tag-and-release

* Introduce verify-npm-package

* Introduce publish-npm-package

* Introduce verify-rust-crate

* Introduce publish-rust-crate

* Introduce verify-rust-wasm

* Introduce publish-rust-wasm

* Introduce modern project workflows

* Introduce the new README
  • Loading branch information
giancosta86 authored Sep 10, 2024
1 parent 089ef62 commit 315d91e
Show file tree
Hide file tree
Showing 73 changed files with 3,972 additions and 119 deletions.
88 changes: 88 additions & 0 deletions .github/test-actions/test-artifact-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Test inject-branch-version and check-artifact-version

runs:
using: composite
steps:
- uses: ./actions/detect-branch-version
id: version-detector

- name: Inject version into Rust crate
uses: ./actions/inject-branch-version
with:
project-directory: ./tests/rust-crate

- name: Inject version into Rust web assembly
uses: ./actions/inject-branch-version
with:
project-directory: ./tests/rust-wasm

- name: Inject version into NodeJS package
uses: ./actions/inject-branch-version
with:
project-directory: ./tests/npm-package

- name: Inject version into unknown project
uses: ./actions/inject-branch-version
with:
artifact-descriptor: some-descriptor.txt
project-directory: ./tests/unknown-tech

- name: Display updated artifacts
shell: bash
run: |
echo "🦀Rust descriptor:"
less ./tests/rust-crate/Cargo.toml
echo
echo "🦀Rust 🌐web assembly descriptor:"
less ./tests/rust-wasm/Cargo.toml
echo
echo "📦NodeJS descriptor:"
less ./tests/npm-package/package.json
echo
echo "🎁Unknown tech descriptor:"
less ./tests/unknown-tech/some-descriptor.txt
echo "🌳🌳🌳"
- name: Version should appear correctly in Rust crate
uses: ./actions/check-artifact-version
with:
project-directory: ./tests/rust-crate

- name: Version should appear correctly in Rust wasm
uses: ./actions/check-artifact-version
with:
project-directory: ./tests/rust-wasm

- name: Version should appear correctly in npm package
uses: ./actions/check-artifact-version
with:
project-directory: ./tests/npm-package

- name: Version should appear correctly in unknown descriptor
shell: bash
run: |
version="${{ steps.version-detector.outputs.version }}"
if ! cat ./tests/unknown-tech/some-descriptor.txt | grep -q "v$version"
then
echo "❌Error while injecting the version into a custom descriptor!" >&2
exit 1
fi
- name: Version should be injected multiple times
shell: bash
run: |
version="${{ steps.version-detector.outputs.version }}"
if ! cat ./tests/unknown-tech/some-descriptor.txt | grep -q "'$version';"
then
echo "❌The version was not injected globally into a custom descriptor!" >&2
exit 1
fi
14 changes: 14 additions & 0 deletions .github/test-actions/test-check-rust-versions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Test check-rust-versions

runs:
using: composite
steps:
- name: Checking Rust versions for Rust crate should work
uses: ./actions/check-rust-versions
with:
project-directory: ./tests/rust-crate

- name: Checking Rust versions for Rust web assembly should work
uses: ./actions/check-rust-versions
with:
project-directory: ./tests/rust-wasm
69 changes: 69 additions & 0 deletions .github/test-actions/test-detect-branch-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Test detect-branch-version

runs:
using: composite
steps:
- uses: ./actions/detect-branch-version
id: detector

- name: Branch should not be empty
shell: bash
run: |
branch="${{ steps.detector.outputs.branch }}"
echo "🔎Branch retrieved from action: '$branch'"
if [[ -z "$branch" ]]
then
echo "❌The branch should not be empty!" >&2
exit 1
fi
- name: The detected branch should be the one starting the pull request for this test
shell: bash
run: |
headRef="${{ github.head_ref }}"
branch="${{ steps.detector.outputs.branch }}"
echo "🔎Head ref in pull request: '$headRef'"
if [[ "$branch" != "$headRef" ]]
then
echo "❌The branch ('$branch') should match the head_ref ('$headRef')!" >&2
exit 1
fi
- name: Version should not be empty
shell: bash
run: |
version="${{ steps.detector.outputs.version }}"
echo "🔎Version retrieved from action: '$version'"
if [[ -z "$version" ]]
then
echo "❌The version should not be empty!" >&2
exit 1
fi
- name: Escaped version should include escaped dots
shell: bash
run: |
escapedVersion="${{ steps.detector.outputs.escaped-version }}"
echo "🔎Escaped version retrieved from action: '$escapedVersion'"
if ! echo "$escapedVersion" | egrep -q "\\\."
then
echo "❌The escaped version should include '\.'!" >&2
exit 1
fi
- name: Major component should not be empty
shell: bash
run: |
major="${{ steps.detector.outputs.major }}"
echo "🔎Major version component: '$major'"
if [[ -z "$major" ]]
then
echo "❌The major component should not be empty!" >&2
exit 1
fi
120 changes: 120 additions & 0 deletions .github/test-actions/test-detect-project-tech/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Test detect-project-tech

runs:
using: composite
steps:
- uses: ./actions/detect-project-tech
id: detect-rust-crate
with:
project-directory: ./tests/rust-crate

- name: Tech for Rust crate should be detected
shell: bash
run: |
tech="${{ steps.detect-rust-crate.outputs.project-tech }}"
echo "🔎Technology retrieved for 🦀Rust: '$tech'"
if [[ "$tech" != "rust" ]]
then
echo "❌Incorrect project tech!" >&2
exit 1
fi
- name: Artifact descriptor for Rust crate should be detected
shell: bash
run: |
artifactDescriptor="${{ steps.detect-rust-crate.outputs.artifact-descriptor }}"
echo "🔎Artifact descriptor retrieved for 🦀Rust: '$artifactDescriptor'"
if [[ "$artifactDescriptor" != "Cargo.toml" ]]
then
echo "❌Incorrect artifact descriptor!" >&2
exit 1
fi
- uses: ./actions/detect-project-tech
id: detect-rust-wasm
with:
project-directory: ./tests/rust-wasm

- name: Tech for Rust web assembly should be detected
shell: bash
run: |
tech="${{ steps.detect-rust-wasm.outputs.project-tech }}"
echo "🔎Technology retrieved for 🦀Rust 🌐web assembly: '$tech'"
if [[ "$tech" != "rust" ]]
then
echo "❌Incorrect project tech!" >&2
exit 1
fi
- name: Artifact descriptor for Rust web assembly should be detected
shell: bash
run: |
artifactDescriptor="${{ steps.detect-rust-wasm.outputs.artifact-descriptor }}"
echo "🔎Artifact descriptor retrieved for 🦀Rust 🌐web assembly: '$artifactDescriptor'"
if [[ "$artifactDescriptor" != "Cargo.toml" ]]
then
echo "❌Incorrect artifact descriptor!" >&2
exit 1
fi
- uses: ./actions/detect-project-tech
id: detect-nodejs-package
with:
project-directory: ./tests/npm-package

- name: Tech for NodeJS package should be detected
shell: bash
run: |
tech="${{ steps.detect-nodejs-package.outputs.project-tech }}"
echo "🔎Technology retrieved for 📦NodeJS: '$tech'"
if [[ "$tech" != "nodejs" ]]
then
echo "❌Incorrect project tech!" >&2
exit 1
fi
- name: Artifact descriptor for NodeJS package should be detected
shell: bash
run: |
artifactDescriptor="${{ steps.detect-nodejs-package.outputs.artifact-descriptor }}"
echo "🔎Artifact descriptor retrieved for 📦NodeJS: '$artifactDescriptor'"
if [[ "$artifactDescriptor" != "package.json" ]]
then
echo "❌Incorrect artifact descriptor!" >&2
exit 1
fi
- uses: ./actions/detect-project-tech
id: detect-unknown-tech
with:
project-directory: ./tests/unknown-tech

- name: Tech for unknown technology should be an empty string
shell: bash
run: |
tech="${{ steps.detect-unknown-tech.outputs.project-tech }}"
echo "🔎Technology retrieved for 🎁unknown stack: '$tech'"
if [[ ! -z "$tech" ]]
then
echo "❌Incorrect project tech!" >&2
exit 1
fi
- name: Artifact descriptor for unknown technology should be an empty string
shell: bash
run: |
artifactDescriptor="${{ steps.detect-unknown-tech.outputs.artifact-descriptor }}"
echo "🔎Artifact descriptor retrieved for 🎁unknown stack: '$artifactDescriptor'"
if [[ ! -z "$artifactDescriptor" ]]
then
echo "❌Incorrect artifact descriptor!" >&2
exit 1
fi
26 changes: 26 additions & 0 deletions .github/test-actions/test-install-wasm-pack/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test install-wasm-pack

runs:
using: composite
steps:
- name: Setup environment variables
shell: bash
run: |
echo "expectedVersion=0.13.0" >> $GITHUB_ENV
- uses: ./actions/install-wasm-pack
with:
wasm-pack-version: ${{ env.expectedVersion }}

- name: The expected wasm-pack version should be available
shell: bash
run: |
wasmPackVersion=$(wasm-pack --version | cut -d' ' -f2)
echo "🔎Detected wasm-pack version: '$wasmPackVersion'"
if [[ "$wasmPackVersion" != "$expectedVersion" ]]
then
echo "❌The expected wasm-pack version ('$expectedVersion') is not installed!" >&2
exit 1
fi
14 changes: 14 additions & 0 deletions .github/test-actions/test-publish-npm-package/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Test publish-npm-package

runs:
using: composite
steps:
- uses: ./actions/inject-branch-version
with:
artifact-descriptor: ./tests/npm-package/package.json

- uses: ./actions/publish-npm-package
with:
dry-run: true
npm-token: ""
project-directory: ./tests/npm-package
14 changes: 14 additions & 0 deletions .github/test-actions/test-publish-rust-crate/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Test publish-rust-crate

runs:
using: composite
steps:
- uses: ./actions/inject-branch-version
with:
artifact-descriptor: ./tests/rust-crate/Cargo.toml

- uses: ./actions/publish-rust-crate
with:
dry-run: true
cargo-token: ""
project-directory: ./tests/rust-crate
16 changes: 16 additions & 0 deletions .github/test-actions/test-publish-rust-wasm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Test publish-rust-wasm

runs:
using: composite
steps:
- uses: ./actions/inject-branch-version
with:
artifact-descriptor: ./tests/rust-wasm/Cargo.toml

- uses: ./actions/publish-rust-wasm
with:
project-directory: ./tests/rust-wasm
dry-run: true
npm-token: ""
wasm-pack-version: 0.13.0
npm-scope: giancosta86
12 changes: 12 additions & 0 deletions .github/test-actions/test-verify-npm-package/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Test verify-npm-package

runs:
using: composite
steps:
- uses: ./actions/inject-branch-version
with:
artifact-descriptor: ./tests/npm-package/package.json

- uses: ./actions/verify-npm-package
with:
project-directory: ./tests/npm-package
12 changes: 12 additions & 0 deletions .github/test-actions/test-verify-rust-crate/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Test verify-rust-crate

runs:
using: composite
steps:
- uses: ./actions/inject-branch-version
with:
artifact-descriptor: ./tests/rust-crate/Cargo.toml

- uses: ./actions/verify-rust-crate
with:
project-directory: ./tests/rust-crate
Loading

0 comments on commit 315d91e

Please sign in to comment.