Skip to content

Build: Bump the go group with 4 updates #1584

Build: Bump the go group with 4 updates

Build: Bump the go group with 4 updates #1584

name: build-playwright-test
on:
pull_request:
types: [opened, reopened, synchronize, labeled, unlabeled]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
name: lint
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cache - node_modules
if: always()
uses: actions/cache@v4
with:
path: |
node_modules
key: ${{ runner.os }}-build-test-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-test-
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Install Dependencies
working-directory: .
run: yarn install --frozen-lockfile
- name: Lint
working-directory: .
run: yarn lint
format:
runs-on: ubuntu-latest
name: format
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cache - node_modules
if: always()
uses: actions/cache@v4
with:
path: |
node_modules
key: ${{ runner.os }}-build-test-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-test-
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Install Dependencies
working-directory: .
run: yarn install --frozen-lockfile
- name: Format code with prettier
working-directory: .
run: yarn format:check
playwright-tests:
runs-on:
- codebuild-content-services-be-repo-${{ github.run_id }}-${{ github.run_attempt }}
- instance-size:large
- buildspec-override:true
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get current PR URL
id: get-pr-url
run: |
# Extract the pull request URL from the event payload
pr_url=$(jq -r '.pull_request.html_url' < "$GITHUB_EVENT_PATH")
echo "Pull Request URL: $pr_url"
# Set the PR URL as an output using the environment file
echo "pr_url=$pr_url" >> $GITHUB_ENV
- name: Get appropriate front-end branch
run: |
chmod +x .github/workflowScripts/getFrontendRepo.sh
.github/workflowScripts/getFrontendRepo.sh "${{ env.pr_url }}"
- name: Create front-end .env file
working-directory: content-sources-frontend
run: |
# Check if the secrets are set
if [ -z "$ADMIN_USERNAME" ]; then
echo "Error: ADMIN_USERNAME secret is not set."
exit 1
fi
if [ -z "$ADMIN_PASSWORD" ]; then
echo "Error: ADMIN_PASSWORD secret is not set."
exit 1
fi
# Create the .env file and write the secrets and other variables to it
{
echo "ADMIN_USERNAME=$ADMIN_USERNAME"
echo "ADMIN_PASSWORD=$ADMIN_PASSWORD"
echo "BASE_URL=https://stage.foo.redhat.com:1337"
echo "CI=true"
} >> .env
echo ".env file created successfully."
- name: Cache - API-test node_modules
uses: actions/cache@v4
with:
path: "node_modules"
key: ${{ runner.os }}-api-node-modules-${{ hashFiles('yarn.lock') }}
restore-keys: ${{ runner.os }}-api-node-modules-
- name: Cache - Front-end-test node_modules
uses: actions/cache@v4
with:
path: "content-sources-frontend/node_modules"
key: ${{ runner.os }}-frontend-node-modules-${{ hashFiles('content-sources-frontend/yarn.lock') }}
restore-keys: ${{ runner.os }}-frontend-node-modules-
- name: Cache - Compose files
uses: actions/cache@v4
with:
path: release
key: ${{ runner.os }}-compose-${{ hashFiles('compose_files/pulp/docker-compose.yml') }}-${{ hashFiles('compose_files/candlepin/Dockerfile') }}
restore-keys: ${{ runner.os }}-compose-
- name: Run get_go_version.sh script
id: get-go-version
run: |
chmod +x ./scripts/get_go_version.sh
GO_VERSION=$(./scripts/get_go_version.sh ./go.mod)
echo "go-version=$GO_VERSION" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "${{ steps.get-go-version.outputs.go-version }}"
- name: Install Make
run: sudo apt-get install make
- name: Install Parallel
run: sudo apt-get install -y parallel
- name: Copy the example config
run: cp ./configs/config.yaml.example ./configs/config.yaml
- name: Create cdn.pem file
run: |
echo "$REDHAT_CDN_CERT" | sed 's/\\n/\n/g' > ./configs/cdn.pem
- name: Update cert_path in config.yaml
run: |
sed -i 's|# cert_path:.*|cert_path: ./configs/cdn.pem|' ./configs/config.yaml
- name: Throw error if cert is invalid
run: |
if ! openssl x509 -in ./configs/cdn.pem -noout; then
echo "Invalid PEM certificate format"
exit 1
fi
echo "PEM certificate is valid"
- name: Check CDN certificate expiry
run: |
# Fail if certificate is expired
NOT_AFTER=$(openssl x509 -in ./configs/cdn.pem -noout -enddate \
| cut -d= -f2)
NOT_AFTER_EPOCH=$(date -d "$NOT_AFTER" +%s)
CURRENT_EPOCH=$(date +%s)
DAYS_UNTIL_EXPIRY=$(( (NOT_AFTER_EPOCH - CURRENT_EPOCH) / 86400 ))
if [[ $DAYS_UNTIL_EXPIRY -le 0 ]]; then
echo "ERROR: CDN certificate has EXPIRED!"
exit 1
else
echo "CDN certificate is valid for $DAYS_UNTIL_EXPIRY more days."
fi
- name: Create backend .env file
working-directory: .
run: |
echo "BASE_URL=http://127.0.0.1:8000" >> .env
echo "TOKEN=apple" >> .env
echo "CI=true" >> .env
echo 'DB_CONNECTION_STRING="postgresql://content:content@localhost:5433/content"' >> .env
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Login to Docker Hub
run: docker login --username "$DOCKER_PULL_USER" --password "$DOCKER_PULL_TOKEN"
- name: Increase file watchers limit
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- name: Setup backend, frontend, and playwright tests
run: 'parallel --line-buffer --tagstring "[{#}]:" ::: "cd content-sources-frontend && yarn install --frozen-lockfile --cache-folder .yarn_cache_frontend && yarn build && yarn playwright install chromium --only-shell" "make compose-down compose-clean compose-up" "yarn install --frozen-lockfile --cache-folder .yarn_cache_backend && yarn playwright install chromium --only-shell"'
- name: Update /etc/hosts
working-directory: content-sources-frontend
run: sudo yarn run patch:hosts
- name: Backend run
run: make run &
- name: Wait for backend to be ready
run: |
chmod +x .github/workflowScripts/waitForBackend.sh
.github/workflowScripts/waitForBackend.sh
- name: Setup the minimal needed repositories (Small RHEL, EPEL 10)
run: make repos-minimal
- name: Wait for setup repos to be valid
timeout-minutes: 3
run: while [[ "$(curl http://localhost:8000/api/content-sources/v1.0/repositories/ -H "$( ./scripts/header.sh 9999 1111)" | jq '.data | all(.status == "Valid")')" == "false" ]]; do sleep 5; done;
- name: Run API Playwright tests
working-directory: .
run: CURRENTS_PROJECT_ID=V4Ri3k CURRENTS_RECORD_KEY=$CURRENTS_RECORD_KEY CURRENTS_CI_BUILD_ID="${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}" yarn playwright test
- name: Publish API Test Report
uses: ctrf-io/github-test-reporter@v1
with:
report-path: "./playwright-ctrf/playwright-ctrf.json"
- name: Store API Test report
uses: actions/upload-artifact@v4
with:
name: playwright-ctrf-backend
path: ./playwright-ctrf
retention-days: 10
- name: Frontend run (static)
working-directory: content-sources-frontend
run: yarn fec static --port 8003 &
- name: Wait for frontend to be ready
working-directory: content-sources-frontend
run: npx wait-on http://localhost:8003/apps/content-sources/
- name: Run testing proxy
working-directory: content-sources-frontend
run: docker run -d --network=host -e HTTPS_PROXY=$RH_PROXY_URL -e ROUTES_JSON_PATH=/config/routes-ci.json -v "$(pwd)/config:/config:ro,Z" --name consoledot-testing-proxy quay.io/dvagner/consoledot-testing-proxy
- name: Run front-end Playwright tests
working-directory: content-sources-frontend
run: CURRENTS_PROJECT_ID=V4Ri3k CURRENTS_RECORD_KEY=$CURRENTS_RECORD_KEY CURRENTS_CI_BUILD_ID="${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}" yarn playwright test
- name: Publish front-end Test Report
uses: ctrf-io/github-test-reporter@v1
with:
report-path: "./content-sources-frontend/playwright-ctrf/playwright-ctrf.json"
- name: Store front-end Test report
uses: actions/upload-artifact@v4
with:
name: playwright-ctrf-frontend
path: ./content-sources-frontend/playwright-ctrf
retention-days: 10