test: 💍 refactor test and configuraiton #134
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continues_Integration_and_Deployment | |
on: | |
push: | |
branches: | |
- 'master' | |
jobs: | |
install-dep: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
/home/runner/.cache/Cypress | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
- name: Install dependencies with Node.js 18.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- run: yarn | |
lint: | |
runs-on: ubuntu-latest | |
needs: install-dep | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
/home/runner/.cache/Cypress | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
- name: Run Lint with Node.js 18.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- run: yarn lint-check | |
test: | |
runs-on: ubuntu-latest | |
needs: install-dep | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
/home/runner/.cache/Cypress | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
- name: Run Test with Node.js 18.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- run: yarn test | |
component_testing: | |
runs-on: ubuntu-latest | |
needs: install-dep | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
/home/runner/.cache/Cypress | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
- name: Cypress Component testing | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- run: yarn cy-run-components | |
- name: Archive cypress videos | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cypress-component-videos | |
path: | | |
./cypress/videos | |
build: | |
runs-on: ubuntu-latest | |
needs: [component_testing, test, lint] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
/home/runner/.cache/Cypress | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Build with envs | |
env: | |
DOTENV_KEY: ${{ secrets.DOTENV_KEY_PROD }} | |
run: yarn build | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: production-build | |
path: | | |
./dist | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: | | |
ghcr.io/${{ github.repository }} | |
- name: Build and push Docker images to e2e test | |
uses: docker/[email protected] | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
version: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
/home/runner/.cache/Cypress | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
- name: Install Latest Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Configure committer | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
- name: Generate Version | |
run: | | |
yarn release | |
- name: Pushing Version | |
run: | | |
git pull | |
git commit --allow-empty -m "[skip ci]" | |
git push --follow-tags origin master | |
creating_release: | |
runs-on: ubuntu-latest | |
needs: version | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
/home/runner/.cache/Cypress | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
- name: Install Latest Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Get package.json version | |
id: get_version | |
run: | | |
echo "version=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT | |
- name: Create Release | |
id: create_release | |
uses: ncipollo/[email protected] | |
with: | |
bodyFile: 'CHANGELOG.md' | |
tag: ${{ steps.get_version.outputs.version }} | |
end_to_end_testing_mobile: | |
runs-on: ubuntu-latest | |
needs: creating_release | |
services: | |
app_to_test: | |
image: ghcr.io/agustinallamanocosta/gtdfront:master | |
options: --name app_to_test | |
env: | |
DOTENV_KEY: ${{ secrets.DOTENV_KEY_CI }} | |
ports: | |
- 8080:8080 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
/home/runner/.cache/Cypress | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
- name: Install Latest Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Run end to end testing Mobile | |
shell: bash | |
env: | |
DOTENV_KEY: ${{ secrets.DOTENV_KEY_CI }} | |
run: yarn cy-run-e2e-mobile | |
- name: Archive cypress videos | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cypress-videos-mobile | |
path: | | |
./cypress/videos | |
- name: Retrieving logs for the service | |
run: | | |
docker logs "${{ job.services.app_to_test.id }}" | |
end_to_end_testing: | |
runs-on: ubuntu-latest | |
needs: end_to_end_testing_mobile | |
services: | |
app_to_test: | |
image: ghcr.io/agustinallamanocosta/gtdfront:master | |
options: --name app_to_test | |
env: | |
DOTENV_KEY: ${{ secrets.DOTENV_KEY_CI }} | |
ports: | |
- 8080:8080 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
/home/runner/.cache/Cypress | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
- name: Install Latest Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Run end to end testing Desktop | |
shell: bash | |
env: | |
DOTENV_KEY: ${{ secrets.DOTENV_KEY_CI }} | |
run: yarn cy-run-e2e | |
- name: Archive cypress videos | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cypress-videos | |
path: | | |
./cypress/videos | |
- name: Retrieving logs for the service | |
run: | | |
docker logs "${{ job.services.app_to_test.id }}" | |
deploy_on_firebase: | |
runs-on: ubuntu-latest | |
needs: [end_to_end_testing, end_to_end_testing_mobile] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
- name: Install Latest Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Download production artifact | |
uses: actions/[email protected] | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
name: production-build | |
path: ./dist | |
- name: Configure Envoironment | |
shell: bash | |
run: | | |
yarn vault-pull production .env --dotenvMe='${{ secrets.DOTENV_ME }}' --yes | |
mv .env ./dist | |
- name: Deploy to Firebase | |
uses: FirebaseExtended/[email protected] | |
with: | |
repoToken: '${{ secrets.GITHUB_TOKEN }}' | |
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GETTHINGSDONE_391622 }}' | |
projectId: getthingsdone-391622 | |
channelId: live |