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

chore: Set up integ tests on gh actions #229

Merged
merged 14 commits into from
Sep 12, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copied from https://raw.githubusercontent.com/aws-amplify/amplify-js/main/.github/actions/load-verdaccio-with-amplify-js/action.yml

name: Load Verdaccio with maplibre-gl-js-amplify
description: Turn on Verdaccio and load up all of the maplibre-gl-js-amplify build artifacts

runs:
using: 'composite'
steps:
- name: Start verdaccio
run: |
npx [email protected] &
while ! nc -z localhost 4873; do
echo "Verdaccio not running yet"
sleep 1
done

# Run your commands after verdaccio is up and running
echo "Verdaccio is up and running, proceeding with the script..."
shell: bash
- name: Install and run npm-cli-login
shell: bash
env:
NPM_REGISTRY: http://localhost:4873/
NPM_USER: verdaccio
NPM_PASS: verdaccio
NPM_EMAIL: [email protected]
run: |
npm i -g npm-cli-adduser
npm-cli-adduser
sleep 1
- name: Configure registry and git
shell: bash
working-directory: ./maplibre-gl-js-amplify
env:
NPM_REGISTRY: http://localhost:4873/
NPM_USER: verdaccio
NPM_PASS: verdaccio
NPM_EMAIL: [email protected]
run: |
yarn config set registry $NPM_REGISTRY
npm set registry $NPM_REGISTRY
git config --global user.email $NPM_EMAIL
git config --global user.name $NPM_USER
git status
git --no-pager diff
- name: Publish to verdaccio
shell: bash
working-directory: ./maplibre-gl-js-amplify
run: |
YARN_REGISTRY=http://localhost:4873/ yarn publish:unstable
YARN_REGISTRY=http://localhost:4873/ yarn info maplibre-gl-js-amplify@unstable description
NPM_CONFIG_REGISTRY=http://localhost:4873 npm info maplibre-gl-js-amplify@unstable version
40 changes: 40 additions & 0 deletions .github/actions/node-and-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copied from https://github.com/aws-amplify/amplify-js/blob/main/.github/actions/node-and-build/action.yml

name: Set Node and Build
description: Checks out Amplify and builds the package
inputs:
is-prebuild:
required: false
default: false
runs:
using: 'composite'
steps:
- name: Setup Node.js 16
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 https://github.com/actions/setup-node/commit/64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
with:
node-version: 16
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
id: cache-build-artifacts
with:
path: |
**/node_modules
**/dist
**/lib
**/lib-esm/
**/es/
**/esm/
**/cjs/
**/packages/core/src/Platform/version.ts
key: ${{ runner.os }}-build-artifacts-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-artifacts-
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
# TODO We should be able to skip yarn / bootstrap if we cache enough things. Leaving because skipping causes issues.
- name: Install
if: inputs.is-prebuild != 'true' || steps.cache-build-artifacts.outputs.cache-hit != 'true'
run: yarn
shell: bash
working-directory: ./maplibre-gl-js-amplify
53 changes: 53 additions & 0 deletions .github/actions/setup-samples-staging/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copied from - https://github.com/aws-amplify/amplify-js/blob/main/.github/actions/load-verdaccio-with-amplify-js/action.yml

name: Setup Amplify Integration Test Package
description: Checks out "amplify-js-samples-staging" and builds the package with caching

inputs:
GH_TOKEN_STAGING_READ:
description: The token that grants read access to the sample staging repo
required: true

runs:
using: 'composite'
steps:
- name: Create cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 https://github.com/actions/cache/commit/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
id: cache-samples-staging-build
with:
key: aws-amplify-js-samples-staging-build-${{ github.sha }}
path: |
./amplify-js-samples-staging/node_modules
/home/runner/.cache/Cypress
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
- name: Checkout staging repo
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
repository: ${{ github.repository_owner }}/amplify-js-samples-staging
path: amplify-js-samples-staging
token: ${{ inputs.GH_TOKEN_STAGING_READ }}

# We test on the staging branch that corresponds to the amplify-js branch
# when it exists and test on the default branch `main` otherwise
- name: Staging repo branch selection
shell: bash
working-directory: ./amplify-js-samples-staging
env:
BRANCH: increase-geo-timeout
run: |
if git ls-remote --exit-code --heads origin $BRANCH >/dev/null 2>&1; then
# Branch exists, checkout and echo success message
git fetch origin $BRANCH
git checkout $BRANCH
echo "Checked out branch: $BRANCH"
else
# Branch doesn't exist, echo error message
echo "Branch '$BRANCH' does not exist"
fi

- name: Install
run: |
yarn
shell: bash
working-directory: ./amplify-js-samples-staging
43 changes: 43 additions & 0 deletions .github/integ-config/integ-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
minimal_browser_list: &minimal_browser_list
- chrome
- firefox

extended_browser_list: &extended_browser_list
- chrome
- firefox
- edge

tests:
# GEO
- test_name: integ_react_geo_display_map
desc: 'Display Map'
framework: react
category: geo
sample_name: [display-map]
spec: display-map
# Temp fix:
browser: [chrome]
- test_name: integ_react_geo_search_outside_map
desc: 'Search Outside Map'
framework: react
category: geo
sample_name: [search-outside-map]
spec: search-outside-map
# Temp fix:
browser: [chrome]
# - test_name: integ_javascript_geo_display_map
# desc: 'Display Map'
# framework: javascript
# category: geo
# sample_name: [display-map-static]
# spec: display-map-static
# browser: *minimal_browser_list
# amplifyjs_dir: true
# - test_name: integ_javascript_geo_search_outside_map
# desc: 'Search Outside Map'
# framework: javascript
# category: geo
# sample_name: [search-outside-map-static]
# spec: search-outside-map-static
# browser: *minimal_browser_list
# amplifyjs_dir: true
121 changes: 121 additions & 0 deletions .github/workflows/callable-e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# copied from https://github.com/aws-amplify/amplify-js/blob/main/.github/workflows/callable-e2e-test.yml

name: E2E Test
run-name: e2e.${{ inputs.test_name }}

on:
workflow_call:
inputs:
test_name:
required: true
type: string
framework:
required: true
type: string
category:
required: true
type: string
sample_name:
required: true
type: string
spec:
required: true
type: string
browser:
required: true
type: string
amplifyjs_dir:
required: true
type: boolean
timeout_minutes:
required: true
type: number
retry_count:
required: true
type: number

env:
AMPLIFY_DIR: /home/runner/work/amplify-js/amplify-js/amplify-js
CYPRESS_GOOGLE_CLIENTID: ${{ secrets.CYPRESS_GOOGLE_CLIENTID }}
CYPRESS_GOOGLE_CLIENT_SECRET: ${{ secrets.CYPRESS_GOOGLE_CLIENT_SECRET }}
CYPRESS_GOOGLE_REFRESH_TOKEN: ${{ secrets.CYPRESS_GOOGLE_REFRESH_TOKEN }}

jobs:
e2e-test:
name: E2E ${{ inputs.test_name }}
runs-on: ubuntu-latest
strategy:
matrix:
browser:
- ${{ fromJson(inputs.browser) }}
sample_name:
- ${{ fromJson(inputs.sample_name) }}
fail-fast: false
timeout-minutes: ${{ inputs.timeout_minutes }}

steps:
- name: Checkout repository
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
path: maplibre-gl-js-amplify
- name: Setup node and build the repository
uses: ./maplibre-gl-js-amplify/.github/actions/node-and-build
- name: Setup samples staging repository
uses: ./maplibre-gl-js-amplify/.github/actions/setup-samples-staging
with:
GH_TOKEN_STAGING_READ: ${{ secrets.GH_TOKEN_STAGING_READ }}
- name: Load Verdaccio with maplibre gl js amplify
uses: ./maplibre-gl-js-amplify/.github/actions/load-verdaccio-with-maplibre-gl-js-amplify
- name: Run cypress tests for ${{ inputs.test_name }} dev
shell: bash
working-directory: ./amplify-js-samples-staging
env:
E2E_FRAMEWORK: ${{ inputs.framework }}
E2E_CATEGORY: ${{ inputs.category }}
E2E_SAMPLE_NAME: ${{ matrix.sample_name }}
E2E_SPEC: ${{ inputs.spec }}
E2E_BROWSER: ${{ matrix.browser }}
E2E_AMPLIFY_JS_DIR: ${{ inputs.amplifyjs_dir == true && env.AMPLIFY_DIR || ''}}
E2E_RETRY_COUNT: ${{ inputs.retry_count }}
E2E_TEST_NAME: ${{ inputs.test_name }}
run: |
yarn ci:test \
$E2E_FRAMEWORK \
$E2E_CATEGORY \
$E2E_SAMPLE_NAME \
$E2E_SPEC \
$E2E_BROWSER \
dev \
$E2E_AMPLIFY_JS_DIR

- name: Run cypress tests for ${{ inputs.test_name }} prod
shell: bash
working-directory: ./amplify-js-samples-staging
env:
E2E_FRAMEWORK: ${{ inputs.framework }}
E2E_CATEGORY: ${{ inputs.category }}
E2E_SAMPLE_NAME: ${{ matrix.sample_name }}
E2E_SPEC: ${{ inputs.spec }}
E2E_BROWSER: ${{ matrix.browser }}
E2E_AMPLIFY_JS_DIR: ${{ inputs.amplifyjs_dir == true && env.AMPLIFY_DIR || ''}}
E2E_RETRY_COUNT: ${{ inputs.retry_count }}
E2E_TEST_NAME: ${{ inputs.test_name }}
run: |
yarn ci:test \
$E2E_FRAMEWORK \
$E2E_CATEGORY \
$E2E_SAMPLE_NAME \
$E2E_SPEC \
$E2E_BROWSER \
prod \
$E2E_AMPLIFY_JS_DIR
- name: Upload artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce
if: failure()
with:
name: ${{ inputs.test_name }}
if-no-files-found: ignore
path: |
amplify-js-samples-staging/cypress/videos
amplify-js-samples-staging/cypress/screenshots
retention-days: 14
42 changes: 42 additions & 0 deletions .github/workflows/callable-e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copied from https://github.com/aws-amplify/amplify-js/blob/main/.github/workflows/callable-e2e-tests.yml

name: E2E Tests

on: workflow_call

jobs:
e2e-prep:
name: Get required configs to run e2e tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
path: maplibre-gl-js-amplify
- name: Read integ config files
id: load_config
run: |
echo "INTEG_CONFIG=$(cat .github/integ-config/integ-all.yml | yq '.tests' -o=json | jq -c .)" >> $GITHUB_OUTPUT
working-directory: ./maplibre-gl-js-amplify
outputs:
integ-config: ${{ steps.load_config.outputs.INTEG_CONFIG }}

e2e-test-runner:
name: E2E test runnner
needs: e2e-prep
secrets: inherit
strategy:
matrix:
integ-config: ${{ fromJson(needs.e2e-prep.outputs.integ-config) }}
fail-fast: false
uses: ./.github/workflows/callable-e2e-test.yml
with:
test_name: ${{ matrix.integ-config.test_name }}
framework: ${{ matrix.integ-config.framework }}
category: ${{ matrix.integ-config.category }}
spec: ${{ matrix.integ-config.spec || '' }}
amplifyjs_dir: ${{ matrix.integ-config.amplifyjs_dir || false }}
sample_name: ${{ toJSON(matrix.integ-config.sample_name) || '[""]' }}
browser: ${{ toJSON(matrix.integ-config.browser) || '[""]' }}
timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 35 }}
retry_count: ${{ matrix.integ-config.retry_count || 3 }}
18 changes: 9 additions & 9 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: "CodeQL"
name: 'CodeQL'

on:
push:
branches: [ "main", "release" ]
branches: ['main', 'release']
pull_request:
branches: [ "main" ]
branches: ['main']

jobs:
analyze:
Expand All @@ -18,22 +18,22 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ javascript ]
language: [javascript]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@d23060145bc9131d50558d5d4185494a20208101 # v2.12.5 https://github.com/github/codeql-action/commit/d23060145bc9131d50558d5d4185494a20208101
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@d23060145bc9131d50558d5d4185494a20208101 # v2.12.5 https://github.com/github/codeql-action/commit/d23060145bc9131d50558d5d4185494a20208101

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@d23060145bc9131d50558d5d4185494a20208101 # v2.12.5 https://github.com/github/codeql-action/commit/d23060145bc9131d50558d5d4185494a20208101
with:
category: "/language:${{ matrix.language }}"
category: '/language:${{ matrix.language }}'
Loading