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

Ci/add pipelines #48

Merged
merged 9 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions .github/workflows/develop-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Develop PR Check
on:
pull_request:
branches: develop

jobs:
test-project:
runs-on: ubuntu-latest

steps:
- name: Check code
uses: actions/checkout@v3

- name: NodeJS Settings
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Install dependencies
run: yarn

- name: Build project
run: yarn build

- name: Start unit tests
run: yarn test
90 changes: 90 additions & 0 deletions .github/workflows/main-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Main PR Check

on:
pull_request:
branches:
- main

jobs:
test-project:
runs-on: ubuntu-latest

steps:
- name: Check code
uses: actions/checkout@v3

- name: NodeJS Settings
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Install dependencies
run: yarn

- name: Build project
run: yarn build

- name: Start unit tests
run: yarn test

compare_versions:
runs-on: ubuntu-latest
needs: test-project
outputs:
create_tag: ${{ steps.compare_versions.outputs.create_tag }}
version: ${{ steps.get_version.outputs.version }}
latest_tag: ${{ steps.get_latest_tag.outputs.latest_tag }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18"

- name: Get project version
id: get_version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" > $GITHUB_ENV

- name: Get latest tag
id: get_latest_tag
run: |
# Fetch tags from the main branch
git fetch origin main --tags
# Get the latest tag from the main branch
TAG=$(git tag --list --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | head -n 1 || echo "0.0.0")
# Remove the 'v' prefix from the tag
CLEAN_TAG=$(echo $TAG | sed 's/^v//')
echo "LATEST_TAG=$CLEAN_TAG" >> $GITHUB_ENV
echo "LATEST_TAG=$CLEAN_TAG" > $GITHUB_ENV

werlleyg marked this conversation as resolved.
Show resolved Hide resolved
- name: Compare versions
id: compare_versions
run: |
# Compare versions
echo "Comparing versions..."

# Ensure both version and tag are properly formatted
LATEST_TAG_VERSION=${LATEST_TAG//v/}

# Ensure correct comparison by adding leading zeroes to ensure numeric comparison
VERSION_PADDED=$(printf "%s\n" "$VERSION" | awk -F. '{printf("%04d%04d%04d", $1, $2, $3)}')
LATEST_TAG_PADDED=$(printf "%s\n" "$LATEST_TAG_VERSION" | awk -F. '{printf("%04d%04d%04d", $1, $2, $3)}')

echo "Padded Project version: $VERSION_PADDED"
echo "Padded Latest tag version: $LATEST_TAG_PADDED"

# Compare the padded versions
if [ "$VERSION_PADDED" -gt "$LATEST_TAG_PADDED" ]; then
echo "Project version $VERSION is greater than latest tag $LATEST_TAG_VERSION"
echo "create_tag=true" >> $GITHUB_ENV
else
echo "Project version $VERSION is not greater than latest tag $LATEST_TAG_VERSION"
echo "create_tag=false" >> $GITHUB_ENV
exit 1
fi
werlleyg marked this conversation as resolved.
Show resolved Hide resolved
93 changes: 93 additions & 0 deletions .github/workflows/main-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Version Check and Create Tag

on:
push:
branches:
- main

jobs:
check_version:
runs-on: ubuntu-latest
outputs:
create_tag: ${{ steps.compare_versions.outputs.create_tag }}
version: ${{ steps.get_version.outputs.version }}
latest_tag: ${{ steps.get_latest_tag.outputs.latest_tag }}

werlleyg marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18"

- name: Get project version
id: get_version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "::set-output name=version::$VERSION"

- name: Get latest tag from main branch
id: get_latest_tag
run: |
# Fetch tags from the main branch
git fetch origin main --tags
# Get the latest tag from the main branch
TAG=$(git tag --list --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | head -n 1 || echo "0.0.0")
# Remove the 'v' prefix from the tag
CLEAN_TAG=$(echo $TAG | sed 's/^v//')
echo "LATEST_TAG=$CLEAN_TAG" >> $GITHUB_ENV
echo "::set-output name=latest_tag::$CLEAN_TAG"

werlleyg marked this conversation as resolved.
Show resolved Hide resolved
- name: Compare versions
id: compare_versions
run: |
echo "Comparing versions..."

# Fetch values from environment
VERSION=${{ env.VERSION }}
LATEST_TAG=${{ env.LATEST_TAG }}

# Ensure both version and tag are properly formatted
VERSION_PADDED=$(printf "%s\n" "$VERSION" | awk -F. '{printf("%04d%04d%04d", $1, $2, $3)}')
LATEST_TAG_PADDED=$(printf "%s\n" "$LATEST_TAG" | awk -F. '{printf("%04d%04d%04d", $1, $2, $3)}')

echo "Padded Project version: $VERSION_PADDED"
echo "Padded Latest tag version: $LATEST_TAG_PADDED"

# Compare the padded versions
if [ "$VERSION_PADDED" -gt "$LATEST_TAG_PADDED" ]; then
echo "Project version $VERSION is greater than latest tag $LATEST_TAG"
echo "::set-output name=create_tag::true"
else
echo "Project version $VERSION is not greater than latest tag $LATEST_TAG"
echo "::set-output name=create_tag::false"
exit 1
fi

create_tag:
runs-on: ubuntu-latest
needs: check_version
if: ${{ needs.check_version.outputs.create_tag == 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Git
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"

- name: Create and push tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="v${{ needs.check_version.outputs.version }}"

# Create a new tag
git tag $TAG

# Push the tag to the remote repository
git push origin $TAG
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quefilme",
"version": "0.1.0",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
1 change: 0 additions & 1 deletion src/main/config/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ export const Environment = {
accessKey: process.env.NEXT_PUBLIC_ACCESS_KEY ?? "15778c95",
baseUrlAi:
process.env.NEXT_PUBLIC_BASE_URL_AI ?? "http://127.0.0.1:3000/api/chat",
debounceTime: process.env.DEBOUNCE_TIME ?? 1,
debounceTime: Number(process.env.DEBOUNCE_TIME) ?? 1,
};
11 changes: 11 additions & 0 deletions tests/presentation/typography/__snapshots__/h3.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`H3 Typography Component Should match the snapshot 1`] = `
<DocumentFragment>
<h3
class="css-16qsii6"
>
Snapshot Test
</h3>
</DocumentFragment>
`;
11 changes: 11 additions & 0 deletions tests/presentation/typography/__snapshots__/h4.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`H4 Typography Component Should match the snapshot 1`] = `
<DocumentFragment>
<h4
class="css-19dnq0y"
>
Snapshot Test
</h4>
</DocumentFragment>
`;
11 changes: 11 additions & 0 deletions tests/presentation/typography/__snapshots__/p.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`P Typography Component Should match the snapshot 1`] = `
<DocumentFragment>
<p
class="snapshot-test css-1watjdo"
>
Snapshot Content
</p>
</DocumentFragment>
`;
Loading
Loading