diff --git a/.circleci/config.yml b/.circleci/config.yml index f376736a31e..0ed88dd150e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,33 +37,6 @@ execution_steps: &execution_steps - run: hostPath=$HOME/.esvu/bin/$hostPath npm run ci jobs: - "Test262: verify tools; build & lint tests": - docker: - - image: cimg/python:3.7.4 - working_directory: ~/test262 - steps: - - checkout - - run: - name: "Install requirements for generation tool" - command: python -m pip install --user --requirement tools/generation/requirements.txt - - run: - name: "Install requirements for lint tool" - command: python -m pip install --user --requirement tools/lint/requirements.txt - - run: - name: "Test the generation tool" - command: ./tools/generation/test/run.py - - run: - name: "Test the lint tool" - command: ./tools/lint/test/run.py - - run: - name: "Build tests; check for new changes" - command: ./tools/scripts/ci_build.sh - - run: - name: "Lint tests" - command: ./tools/scripts/ci_lint.sh - # - run: - # name: "Run deploy" - # command: ./tools/scripts/deploy.sh "V8: New or modified tests execution": docker: - image: *node_image @@ -135,9 +108,6 @@ jobs: <<: [*execution_steps] workflows: version: 2 - Tools: - jobs: - - "Test262: verify tools; build & lint tests" Tests execution: jobs: # - "ChakraCore: New or modified tests execution" diff --git a/.editorconfig b/.editorconfig index bae1a5a6660..380e57acad9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,7 +7,7 @@ end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true -[{README.md,package.json,.travis.yml,*.sh,*.js,*.case,*.template}] +[{README.md,package.json,*.yml,*.sh,*.js,*.case,*.template}] indent_style = space indent_size = 2 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 00000000000..817ab13ad81 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,87 @@ +name: Checks + +on: + - push + - pull_request + +jobs: + lint: + name: Lint tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + cache: pip + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r tools/lint/requirements.txt + + - name: Lint all tests + if: github.event_name == 'push' + run: ./tools/lint/lint.py test/ + + - name: Identify new or changed tests + id: changed_tests + if: github.event_name == 'pull_request' + uses: tj-actions/changed-files@v45 + with: + files: test/ + + - name: Lint new or changed tests + if: | + github.event_name == 'pull_request' && + steps.changed_tests.outputs.any_changed == 'true' + env: + CHANGED: ${{ steps.changed_tests.outputs.all_changed_files }} + run: | + echo New or modified test files: + for file in $CHANGED; do + echo $file + done + ./tools/lint/lint.py $CHANGED 2> >(tee errors.out >&2) + + - name: Create annotations in the PR + if: failure() && github.event_name == 'pull_request' + run: | + awk -F': ' /dev/null + ./make.py + + - name: Verify changes + uses: tj-actions/verify-changed-files@v20 + with: + fail-if-changed: true + fail-message: | + New changes were found after re-generating the tests. + Please read the documentation on procedurally generated tests + https://github.com/tc39/test262/blob/HEAD/CONTRIBUTING.md#procedurally-generated-tests diff --git a/.github/workflows/esmeta-test262.yml b/.github/workflows/esmeta-test262.yml index 59593708792..1404303266d 100644 --- a/.github/workflows/esmeta-test262.yml +++ b/.github/workflows/esmeta-test262.yml @@ -30,14 +30,20 @@ jobs: - name: build esmeta working-directory: ${{ env.ESMETA_HOME }} run: sbt assembly + + - name: Identify new or changed tests + id: changed_tests + uses: tj-actions/changed-files@v45 + with: + files: test/ + - name: run test262 + if: steps.changed_tests.outputs.any_changed == 'true' + env: + CHANGED: ${{ steps.changed_tests.outputs.all_changed_files }} run: | - git fetch origin main - paths=$(git diff --diff-filter ACMR --name-only origin/main.. -- test/) - if [ "$paths" == "" ]; then - echo No test files added or modified. Exiting. - exit 0 - fi echo New or modified test files: - echo "$paths" - "${ESMETA_HOME}"/bin/esmeta test262-test -status -test262dir=$(pwd) $paths + for file in $CHANGED; do + echo $file + done + "${ESMETA_HOME}"/bin/esmeta test262-test -status -test262dir=$(pwd) $CHANGED diff --git a/.github/workflows/test-tools.yml b/.github/workflows/test-tools.yml new file mode 100644 index 00000000000..750310b785c --- /dev/null +++ b/.github/workflows/test-tools.yml @@ -0,0 +1,52 @@ +name: Test tools + +on: + push: + files: + - 'tools/**' + pull_request: + files: + - 'tools/**' + +jobs: + lint: + name: Test the lint tool + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + cache: pip + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r tools/lint/requirements.txt + + - name: Test the lint tool + run: ./tools/lint/test/run.py + + generation: + name: Test the generation tool + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + cache: pip + + - name: Install dependencies for generation tool + run: | + python -m pip install --upgrade pip + pip install -r tools/generation/requirements.txt + + - name: Test the generation tool + run: ./tools/generation/test/run.py diff --git a/make.py b/make.py index 29036615f5d..2f5cf91d2a6 100755 --- a/make.py +++ b/make.py @@ -7,8 +7,6 @@ OUT_DIR = os.environ.get('OUT_DIR') or 'test' SRC_DIR = os.environ.get('SRC_DIR') or 'src' -UPSTREAM = os.environ.get('UPSTREAM') or 'git@github.com:tc39/test262.git' -MAINTAINER = os.environ.get('MAINTAINER') or 'test262@ecma-international.org' def shell(*args): sp = subprocess.Popen(list(args), stdout=subprocess.PIPE, universal_newlines=True) @@ -50,32 +48,6 @@ def build(): def clean(): shell(sys.executable, 'tools/generation/generator.py', 'clean', OUT_DIR) -@target('clean', 'build') -def deploy(): - shell('git', 'add', '--all', OUT_DIR) - shell('git', 'commit', '--message', '"Re-build from source"') - shell('git', 'push', UPSTREAM, 'main') - shell('git', 'checkout', '-') - -# Generate a deploy key for use in a continuous integration system, allowing -# for automated deployment in response to merge events. -@target() -def github_deploy_key(): - shell('ssh-keygen', - '-t', 'rsa', - '-b', '4096', - '-C', MAINTAINER, - '-f', 'github-deploy-key') - -# Encrypt the deploy key so that it may be included in the repository (to be -# decrypted by the continuous integration server during automated deployment) -# This requires the "travis" Ruby gem -# Source: https://docs.travis-ci.com/user/encrypting-files/ -@target('github_deploy_key') -def github_deploy_key_enc(): - shell('travis', 'login') - shell('travis', 'encrypt-file', 'github-deploy-key') - if len(sys.argv) == 1: targets['build']() diff --git a/tools/lint/lint.py b/tools/lint/lint.py index 9f0dca28118..b8eaa86e868 100755 --- a/tools/lint/lint.py +++ b/tools/lint/lint.py @@ -97,7 +97,11 @@ def lint(file_names, features): if args.exceptions: exceptions = lib.exceptions.parse(args.exceptions) else: - exceptions = dict() + try: + with open('lint.exceptions', 'r') as default_exceptions: + exceptions = lib.exceptions.parse(default_exceptions) + except FileNotFoundError: + exceptions = dict() files = [path for _path in args.path for path in collect_files(_path)] file_count = len(files) diff --git a/tools/scripts/ci_build.sh b/tools/scripts/ci_build.sh deleted file mode 100755 index ad3e8abce99..00000000000 --- a/tools/scripts/ci_build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -if [ "$CIRCLE_PULL_REQUEST" != "" ]; then - ./make.py clean > /dev/null -fi -./make.py - -if [ -n "$(git status --porcelain)" -a "$CIRCLE_PULL_REQUEST" != "" ]; then - echo New changes were found after re-generating the tests. - echo "" - git status --porcelain; - echo "" - git diff; - echo "" - echo Please, read the documentation on procedurally generated tests - echo 'https://github.com/tc39/test262/blob/HEAD/CONTRIBUTING.md#procedurally-generated-tests' - exit 1 -fi diff --git a/tools/scripts/ci_lint.sh b/tools/scripts/ci_lint.sh deleted file mode 100755 index bb5ec545396..00000000000 --- a/tools/scripts/ci_lint.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -if [ "$CIRCLE_PULL_REQUEST" != "" ]; then - paths=$(git diff --diff-filter ACMR --name-only origin/main.. -- test/) - - if [ "$paths" == "" ]; then - echo No test files added or modified. Exiting. - exit 0 - fi - - echo New or modified test files: - echo "$paths" - -else - paths="test/" -fi - -./tools/lint/lint.py --exceptions lint.exceptions $paths diff --git a/tools/scripts/deploy.sh b/tools/scripts/deploy.sh deleted file mode 100755 index c6ebb9f255c..00000000000 --- a/tools/scripts/deploy.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -if [ $CIRCLE_EVENT_TYPE != "push" -o $CIRCLE_BRANCH != "main" ]; then - echo This job is not running against a commit that has been merged to main. - echo Skipping deployment. - exit 0 -fi -openssl aes-256-cbc \ - -K $encrypted_4c3763264a8a_key \ - -iv $encrypted_4c3763264a8a_iv \ - -in github-deploy-key.enc \ - -out github-deploy-key \ - -d -chmod 600 github-deploy-key -eval "$(ssh-agent -s)" -ssh-add github-deploy-key -rm github-deploy-key -git config --global user.email "test262@ecma-international.org" -git config --global user.name "Test262 Automation Script" -# The repository on TravisCI is a shallow clone, so the `main` branch must -# be retrieved explicitly, and a local branch created from the `FETCH_HEAD` -# git reference -git fetch origin main -git branch main FETCH_HEAD -./make.py deploy