From 4f6ca4a3a57d6092dd4e53c1ba5a8c9c61eeac1d Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Fri, 22 Sep 2023 12:49:09 -0500 Subject: [PATCH 1/8] Create pipeline in Buildkite --- {.ci => .buildkite}/Dockerfile | 0 {.ci => .buildkite}/certs/ca.crt | 0 {.ci => .buildkite}/certs/ca.pem | 0 {.ci => .buildkite}/certs/testnode.crt | 0 {.ci => .buildkite}/certs/testnode.key | 0 {.ci => .buildkite}/functions/cleanup.sh | 2 +- {.ci => .buildkite}/functions/imports.sh | 0 .../functions/wait-for-container.sh | 2 +- .buildkite/pipeline.yml | 40 ++++++++++++++- {.ci => .buildkite}/run-elasticsearch.sh | 2 +- {.ci => .buildkite}/run-nox.sh | 0 .buildkite/run-repository.sh | 49 +++++++++++++++++++ {.ci => .buildkite}/run-tests | 18 +++---- .ci/run-repository.sh | 48 ------------------ .ci/test-matrix.yml | 18 ------- CONTRIBUTING.md | 2 +- noxfile.py | 7 ++- 17 files changed, 106 insertions(+), 82 deletions(-) rename {.ci => .buildkite}/Dockerfile (100%) rename {.ci => .buildkite}/certs/ca.crt (100%) rename {.ci => .buildkite}/certs/ca.pem (100%) rename {.ci => .buildkite}/certs/testnode.crt (100%) rename {.ci => .buildkite}/certs/testnode.key (100%) rename {.ci => .buildkite}/functions/cleanup.sh (96%) rename {.ci => .buildkite}/functions/imports.sh (100%) rename {.ci => .buildkite}/functions/wait-for-container.sh (94%) rename {.ci => .buildkite}/run-elasticsearch.sh (98%) rename {.ci => .buildkite}/run-nox.sh (100%) create mode 100755 .buildkite/run-repository.sh rename {.ci => .buildkite}/run-tests (50%) delete mode 100755 .ci/run-repository.sh delete mode 100644 .ci/test-matrix.yml diff --git a/.ci/Dockerfile b/.buildkite/Dockerfile similarity index 100% rename from .ci/Dockerfile rename to .buildkite/Dockerfile diff --git a/.ci/certs/ca.crt b/.buildkite/certs/ca.crt similarity index 100% rename from .ci/certs/ca.crt rename to .buildkite/certs/ca.crt diff --git a/.ci/certs/ca.pem b/.buildkite/certs/ca.pem similarity index 100% rename from .ci/certs/ca.pem rename to .buildkite/certs/ca.pem diff --git a/.ci/certs/testnode.crt b/.buildkite/certs/testnode.crt similarity index 100% rename from .ci/certs/testnode.crt rename to .buildkite/certs/testnode.crt diff --git a/.ci/certs/testnode.key b/.buildkite/certs/testnode.key similarity index 100% rename from .ci/certs/testnode.key rename to .buildkite/certs/testnode.key diff --git a/.ci/functions/cleanup.sh b/.buildkite/functions/cleanup.sh similarity index 96% rename from .ci/functions/cleanup.sh rename to .buildkite/functions/cleanup.sh index 4c25166fb..98dfe4e14 100755 --- a/.ci/functions/cleanup.sh +++ b/.buildkite/functions/cleanup.sh @@ -2,7 +2,7 @@ # # Shared cleanup routines between different steps # -# Please source .ci/functions/imports.sh as a whole not just this file +# Please source .buildkite/functions/imports.sh as a whole not just this file # # Version 1.0.0 # - Initial version after refactor diff --git a/.ci/functions/imports.sh b/.buildkite/functions/imports.sh similarity index 100% rename from .ci/functions/imports.sh rename to .buildkite/functions/imports.sh diff --git a/.ci/functions/wait-for-container.sh b/.buildkite/functions/wait-for-container.sh similarity index 94% rename from .ci/functions/wait-for-container.sh rename to .buildkite/functions/wait-for-container.sh index 1a721b588..bbbf4ea63 100755 --- a/.ci/functions/wait-for-container.sh +++ b/.buildkite/functions/wait-for-container.sh @@ -2,7 +2,7 @@ # # Exposes a routine scripts can call to wait for a container if that container set up a health command # -# Please source .ci/functions/imports.sh as a whole not just this file +# Please source .buildkite/functions/imports.sh as a whole not just this file # # Version 1.0.1 # - Initial version after refactor diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index ffb9ebab5..9eccb5a28 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,3 +1,39 @@ +--- steps: - - label: ":python: Greetings" - command: "echo 'Hello, world!'" + - label: ":python: :elasticsearch:" + agents: + provider: gcp + matrix: + setup: + stack_version: + - "8.11.0-SNAPSHOT" + test_suite: + - platinum + python: + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "3.11" + connection_class: + - urllib3 + - requests + env: + STACK_VERSION: "{{ matrix.stack_version }}" + TEST_SUITE: "{{ matrix.test_suite }}" + PYTHON_VERSION: "{{ matrix.python }}" + PYTHON_CONNECTION_CLASS: "{{ matrix.connection_class }}" + command: ./.buildkite/run-tests + artifact_paths: "junit/*-junit.xml" + - wait: ~ + continue_on_failure: true + - label: ":junit: Test results" + agents: + provider: "gcp" + image: family/core-ubuntu-2204 + plugins: + - junit-annotate#v2.4.1: + artifacts: "junit/*-junit.xml" + job-uuid-file-pattern: "(.*)-junit.xml" + fail-build-on-error: true + failure-format: file diff --git a/.ci/run-elasticsearch.sh b/.buildkite/run-elasticsearch.sh similarity index 98% rename from .ci/run-elasticsearch.sh rename to .buildkite/run-elasticsearch.sh index 05046db9c..7f6e77759 100755 --- a/.ci/run-elasticsearch.sh +++ b/.buildkite/run-elasticsearch.sh @@ -25,7 +25,7 @@ script_path=$(dirname $(realpath -s $0)) source $script_path/functions/imports.sh set -euo pipefail -echo -e "\033[34;1mINFO:\033[0m Take down node if called twice with the same arguments (DETACH=true) or on seperate terminals \033[0m" +echo -e "\033[34;1mINFO:\033[0m Take down node if called twice with the same arguments (DETACH=true) or on separate terminals \033[0m" cleanup_node $es_node_name master_node_name=${es_node_name} diff --git a/.ci/run-nox.sh b/.buildkite/run-nox.sh similarity index 100% rename from .ci/run-nox.sh rename to .buildkite/run-nox.sh diff --git a/.buildkite/run-repository.sh b/.buildkite/run-repository.sh new file mode 100755 index 000000000..5f204901b --- /dev/null +++ b/.buildkite/run-repository.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# Called by entry point `run-test` use this script to add your repository specific test commands +# Once called Elasticsearch is up and running and the following parameters are available to this script + +# STACK_VERSION -- version e.g Major.Minor.Patch(-Prelease) +# elasticsearch_container -- the docker moniker as a reference to know which docker image distribution is used +# elasticsearch_url -- The url at which elasticsearch is reachable +# network_name -- The docker network name +# node_name -- The docker container name also used as Elasticsearch node name + +# When run in CI the test-matrix is used to define additional variables +# TEST_SUITE -- either `oss` or `xpack`, defaults to `oss` in `run-tests` + +set -e + +echo -e "\033[34;1mINFO:\033[0m URL $elasticsearch_url\033[0m" +echo -e "\033[34;1mINFO:\033[0m VERSION $STACK_VERSION\033[0m" +echo -e "\033[34;1mINFO:\033[0m CONTAINER $elasticsearch_container\033[0m" +echo -e "\033[34;1mINFO:\033[0m TEST_SUITE $TEST_SUITE\033[0m" +echo -e "\033[34;1mINFO:\033[0m PYTHON_VERSION $PYTHON_VERSION\033[0m" +echo -e "\033[34;1mINFO:\033[0m PYTHON_CONNECTION_CLASS $PYTHON_CONNECTION_CLASS\033[0m" + +echo "--- :docker: :python: Build elastic/elasticsearch-py container" + +docker build \ + --file .buildkite/Dockerfile \ + --tag elastic/elasticsearch-py \ + --build-arg "PYTHON_VERSION=$PYTHON_VERSION" \ + --build-arg "BUILDER_UID=$(id -u)" \ + --build-arg "BUILDER_GID=$(id -g)" \ + . + +echo "--- :docker: :python: Run elastic/elasticsearch-py container" + +mkdir -p "$(pwd)/junit" +docker run \ + -u "$(id -u):$(id -g)" \ + --network="$network_name" \ + -e STACK_VERSION \ + -e "ELASTICSEARCH_URL=$elasticsearch_url" \ + -e TEST_SUITE \ + -e PYTHON_CONNECTION_CLASS \ + -v "$(pwd)/junit:/junit" \ + --name elasticsearch-py \ + --rm \ + elastic/elasticsearch-py \ + + bash -c "nox -s test-$PYTHON_VERSION; [ -f ./junit/$BUILDKITE_JOB_ID-junit.xml ] && mv ./junit/$BUILDKITE_JOB_ID-junit.xml /junit || echo 'No JUnit artifact found'" diff --git a/.ci/run-tests b/.buildkite/run-tests similarity index 50% rename from .ci/run-tests rename to .buildkite/run-tests index b72b112b3..5fa2ce78a 100755 --- a/.ci/run-tests +++ b/.buildkite/run-tests @@ -1,7 +1,7 @@ #!/usr/bin/env bash # # Version 1.1 -# - Moved to .ci folder and seperated out `run-repository.sh` +# - Moved to .buildkite folder and separated out `run-repository.sh` # - Add `$RUNSCRIPTS` env var for running Elasticsearch dependent products # Default environment variables @@ -11,20 +11,20 @@ export PYTHON_VERSION="${PYTHON_VERSION:=3.9}" export PYTHON_CONNECTION_CLASS="${PYTHON_CONNECTION_CLASS:=urllib3}" script_path=$(dirname $(realpath -s $0)) -source $script_path/functions/imports.sh +source "$script_path/functions/imports.sh" set -euo pipefail -echo -e "\033[1m>>>>> Start [$STACK_VERSION container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m" -DETACH=true bash .ci/run-elasticsearch.sh +echo "--- :elasticsearch: Starting Elasticsearch $STACK_VERSION" +DETACH=true bash .buildkite/run-elasticsearch.sh if [[ -n "$RUNSCRIPTS" ]]; then for RUNSCRIPT in ${RUNSCRIPTS//,/ } ; do - echo -e "\033[1m>>>>> Running run-$RUNSCRIPT.sh >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m" - CONTAINER_NAME=${RUNSCRIPT} \ + echo "--- Running run-$RUNSCRIPT.sh" + CONTAINER_NAME="$RUNSCRIPT" \ DETACH=true \ - bash .ci/run-${RUNSCRIPT}.sh + bash ".buildkite/run-$RUNSCRIPT.sh" done fi -echo -e "\033[1m>>>>> Repository specific tests >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m" -bash .ci/run-repository.sh +echo "--- :python: Run tests" +bash .buildkite/run-repository.sh diff --git a/.ci/run-repository.sh b/.ci/run-repository.sh deleted file mode 100755 index 7a5b5b9e1..000000000 --- a/.ci/run-repository.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash - -# Called by entry point `run-test` use this script to add your repository specific test commands -# Once called Elasticsearch is up and running and the following parameters are available to this script - -# ELASTICSEARCH_VERSION -- version e.g Major.Minor.Patch(-Prelease) -# ELASTICSEARCH_CONTAINER -- the docker moniker as a reference to know which docker image distribution is used -# ELASTICSEARCH_URL -- The url at which elasticsearch is reachable -# NETWORK_NAME -- The docker network name -# NODE_NAME -- The docker container name also used as Elasticsearch node name - -# When run in CI the test-matrix is used to define additional variables -# TEST_SUITE -- either `oss` or `xpack`, defaults to `oss` in `run-tests` - -set -e - -echo -e "\033[34;1mINFO:\033[0m URL ${ELASTICSEARCH_URL}\033[0m" -echo -e "\033[34;1mINFO:\033[0m VERSION ${ELASTICSEARCH_VERSION}\033[0m" -echo -e "\033[34;1mINFO:\033[0m CONTAINER ${ELASTICSEARCH_CONTAINER}\033[0m" -echo -e "\033[34;1mINFO:\033[0m TEST_SUITE ${TEST_SUITE}\033[0m" -echo -e "\033[34;1mINFO:\033[0m PYTHON_VERSION ${PYTHON_VERSION}\033[0m" -echo -e "\033[34;1mINFO:\033[0m PYTHON_CONNECTION_CLASS ${PYTHON_CONNECTION_CLASS}\033[0m" - -echo -e "\033[1m>>>>> Build [elastic/elasticsearch-py container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m" - -docker build \ - --file .ci/Dockerfile \ - --tag elastic/elasticsearch-py \ - --build-arg "PYTHON_VERSION=${PYTHON_VERSION}" \ - --build-arg "BUILDER_UID=$(id -u)" \ - --build-arg "BUILDER_GID=$(id -g)" \ - . - -echo -e "\033[1m>>>>> Run [elastic/elasticsearch-py container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m" - -mkdir -p junit -docker run \ - -u "$(id -u):$(id -g)" \ - --network=${network_name} \ - --env "STACK_VERSION=${STACK_VERSION}" \ - --env "ELASTICSEARCH_URL=${elasticsearch_url}" \ - --env "TEST_SUITE=${TEST_SUITE}" \ - --env "PYTHON_CONNECTION_CLASS=${PYTHON_CONNECTION_CLASS}" \ - --env "TEST_TYPE=server" \ - --name elasticsearch-py \ - --rm \ - elastic/elasticsearch-py \ - nox -s test-${PYTHON_VERSION} diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml deleted file mode 100644 index 866b1e7b0..000000000 --- a/.ci/test-matrix.yml +++ /dev/null @@ -1,18 +0,0 @@ -STACK_VERSION: - - "8.11.0-SNAPSHOT" - -TEST_SUITE: - - platinum - -PYTHON_VERSION: - - "3.7" - - "3.8" - - "3.9" - - "3.10" - - "3.11" - -PYTHON_CONNECTION_CLASS: - - urllib3 - - requests - -exclude: ~ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 50e89c62b..4d83ec97c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,7 @@ before writing too much code. ## Running Elasticsearch locally We've provided a script to start an Elasticsearch cluster of a certain version -found at `.ci/run-elasticsearch.sh`. +found at `.buildkite/run-elasticsearch.sh`. There are several environment variables that control integration tests: diff --git a/noxfile.py b/noxfile.py index 3dfa178be..a7abda2fb 100644 --- a/noxfile.py +++ b/noxfile.py @@ -36,7 +36,12 @@ def test(session): session.install("-r", "dev-requirements.txt") python_version = tuple(int(x) for x in session.python.split(".")) - junit_xml = os.path.join(SOURCE_DIR, "junit", "elasticsearch-py-junit.xml") + job_id = os.environ.get('BUILDKITE_JOB_ID', None) + if job_id is not None: + junit_xml = os.path.join(SOURCE_DIR, "junit", f"{job_id}-junit.xml") + else: + junit_xml = os.path.join(SOURCE_DIR, "junit", "elasticsearch-py-junit.xml") + pytest_argv = [ "pytest", "--cov-report=term-missing", From 641372fd441977a72e2d9b9a00fe97b07ffde9e0 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Fri, 22 Sep 2023 12:50:55 -0500 Subject: [PATCH 2/8] Drop jobs from Jenkins --- .ci/jobs/defaults.yml | 76 ------------------- .ci/jobs/elastic+elasticsearch-py+7.17.yml | 12 --- .ci/jobs/elastic+elasticsearch-py+8.3.yml | 12 --- .ci/jobs/elastic+elasticsearch-py+8.4.yml | 12 --- .ci/jobs/elastic+elasticsearch-py+main.yml | 12 --- .../elastic+elasticsearch-py+pull-request.yml | 19 ----- 6 files changed, 143 deletions(-) delete mode 100644 .ci/jobs/defaults.yml delete mode 100644 .ci/jobs/elastic+elasticsearch-py+7.17.yml delete mode 100644 .ci/jobs/elastic+elasticsearch-py+8.3.yml delete mode 100644 .ci/jobs/elastic+elasticsearch-py+8.4.yml delete mode 100644 .ci/jobs/elastic+elasticsearch-py+main.yml delete mode 100644 .ci/jobs/elastic+elasticsearch-py+pull-request.yml diff --git a/.ci/jobs/defaults.yml b/.ci/jobs/defaults.yml deleted file mode 100644 index 6c8292672..000000000 --- a/.ci/jobs/defaults.yml +++ /dev/null @@ -1,76 +0,0 @@ ---- - -##### GLOBAL METADATA - -- meta: - cluster: clients-ci - -##### JOB DEFAULTS - -- job: - project-type: matrix - logrotate: - daysToKeep: 30 - numToKeep: 100 - properties: - - github: - url: https://github.com/elastic/elasticsearch-py/ - - inject: - properties-content: HOME=$JENKINS_HOME - concurrent: true - node: flyweight - scm: - - git: - name: origin - credentials-id: f6c7695a-671e-4f4f-a331-acdce44ff9ba - reference-repo: /var/lib/jenkins/.git-references/elasticsearch-py.git - branches: - - ${branch_specifier} - url: git@github.com:elastic/elasticsearch-py.git - wipe-workspace: 'True' - triggers: - - github - - timed: 'H */12 * * *' - axes: - - axis: - type: slave - name: label - values: - - linux - - axis: - type: yaml - filename: .ci/test-matrix.yml - name: STACK_VERSION - - axis: - type: yaml - filename: .ci/test-matrix.yml - name: PYTHON_VERSION - - axis: - type: yaml - filename: .ci/test-matrix.yml - name: PYTHON_CONNECTION_CLASS - - axis: - type: yaml - filename: .ci/test-matrix.yml - name: TEST_SUITE - yaml-strategy: - exclude-key: exclude - filename: .ci/test-matrix.yml - wrappers: - - ansicolor - - timeout: - type: absolute - timeout: 120 - fail: true - - timestamps - - workspace-cleanup - builders: - - shell: |- - #!/usr/local/bin/runbld - .ci/run-tests - publishers: - - email: - recipients: build-lang-clients@elastic.co - - junit: - results: "junit/*-junit.xml" - allow-empty-results: true diff --git a/.ci/jobs/elastic+elasticsearch-py+7.17.yml b/.ci/jobs/elastic+elasticsearch-py+7.17.yml deleted file mode 100644 index 6424bdb25..000000000 --- a/.ci/jobs/elastic+elasticsearch-py+7.17.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- job: - name: elastic+elasticsearch-py+7.17 - display-name: 'elastic / elasticsearch-py # 7.17' - description: Testing the elasticsearch-py 7.17 branch. - junit_results: "*-junit.xml" - parameters: - - string: - name: branch_specifier - default: refs/heads/7.17 - description: the Git branch specifier to build (<branchName>, <tagName>, - <commitId>, etc.) diff --git a/.ci/jobs/elastic+elasticsearch-py+8.3.yml b/.ci/jobs/elastic+elasticsearch-py+8.3.yml deleted file mode 100644 index 44b1b20aa..000000000 --- a/.ci/jobs/elastic+elasticsearch-py+8.3.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- job: - name: elastic+elasticsearch-py+8.5 - display-name: 'elastic / elasticsearch-py # 8.5' - description: Testing the elasticsearch-py 8.5 branch. - junit_results: "*-junit.xml" - parameters: - - string: - name: branch_specifier - default: refs/heads/8.5 - description: the Git branch specifier to build (<branchName>, <tagName>, - <commitId>, etc.) diff --git a/.ci/jobs/elastic+elasticsearch-py+8.4.yml b/.ci/jobs/elastic+elasticsearch-py+8.4.yml deleted file mode 100644 index 4b71f8e54..000000000 --- a/.ci/jobs/elastic+elasticsearch-py+8.4.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- job: - name: elastic+elasticsearch-py+8.4 - display-name: 'elastic / elasticsearch-py # 8.4' - description: Testing the elasticsearch-py 8.4 branch. - junit_results: "*-junit.xml" - parameters: - - string: - name: branch_specifier - default: refs/heads/8.4 - description: the Git branch specifier to build (<branchName>, <tagName>, - <commitId>, etc.) diff --git a/.ci/jobs/elastic+elasticsearch-py+main.yml b/.ci/jobs/elastic+elasticsearch-py+main.yml deleted file mode 100644 index 00bf73337..000000000 --- a/.ci/jobs/elastic+elasticsearch-py+main.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- job: - name: elastic+elasticsearch-py+main - display-name: 'elastic / elasticsearch-py # main' - description: Testing the elasticsearch-py main branch. - junit_results: "*-junit.xml" - parameters: - - string: - name: branch_specifier - default: refs/heads/main - description: the Git branch specifier to build (<branchName>, <tagName>, - <commitId>, etc.) diff --git a/.ci/jobs/elastic+elasticsearch-py+pull-request.yml b/.ci/jobs/elastic+elasticsearch-py+pull-request.yml deleted file mode 100644 index 813fff243..000000000 --- a/.ci/jobs/elastic+elasticsearch-py+pull-request.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- job: - name: elastic+elasticsearch-py+pull-request - display-name: 'elastic / elasticsearch-py # pull-request' - description: Testing of elasticsearch-py pull requests. - junit_results: "*-junit.xml" - scm: - - git: - branches: - - ${ghprbActualCommit} - refspec: +refs/pull/*:refs/remotes/origin/pr/* - triggers: - - github-pull-request: - org-list: - - elastic - allow-whitelist-orgs-as-admins: true - github-hooks: true - status-context: clients-ci - cancel-builds-on-update: true From a51960b2ee908aa1bd3ad951c4ab9ec809a25654 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Fri, 22 Sep 2023 12:51:10 -0500 Subject: [PATCH 3/8] Add catalog-info.yaml --- catalog-info.yaml | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 catalog-info.yaml diff --git a/catalog-info.yaml b/catalog-info.yaml new file mode 100644 index 000000000..0a731b1a0 --- /dev/null +++ b/catalog-info.yaml @@ -0,0 +1,44 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/catalog-info.json +apiVersion: backstage.io/v1alpha1 +kind: Component +metadata: + name: elasticsearch-py +spec: + type: library + owner: group:clients-team + lifecycle: production + +--- +# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json +apiVersion: backstage.io/v1alpha1 +kind: Resource +metadata: + name: elasticsearch-py-test + description: Test elasticsearch-py client +spec: + type: buildkite-pipeline + owner: group:clients-team + system: buildkite + implementation: + apiVersion: buildkite.elastic.dev/v1 + kind: Pipeline + metadata: + name: elasticsearch-py-test + spec: + repository: elastic/elasticsearch-py + pipeline_file: .buildkite/pipeline.yaml + teams: + clients-team: + access_level: MANAGE_BUILD_AND_READ + everyone: + access_level: READ_ONLY + provider_settings: + build_pull_requests: true + build_branches: true + cancel_intermediate_builds: true + cancel_intermediate_builds_branch_filter: '!main' + schedules: + main_semi_daily: + branch: 'main' + cronline: '0 */12 * * *' From 0e84eac286a261de47fe9b799c3c580bb45c370d Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Fri, 22 Sep 2023 13:11:46 -0500 Subject: [PATCH 4/8] Update references to moved files --- .ci/make.sh | 2 +- .github/workflows/ci.yml | 2 +- .github/workflows/unified-release.yml | 2 +- test_elasticsearch/utils.py | 2 +- utils/bump-version.py | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.ci/make.sh b/.ci/make.sh index b628df473..b5fce58a5 100755 --- a/.ci/make.sh +++ b/.ci/make.sh @@ -114,7 +114,7 @@ echo -e "\033[34;1mINFO: building $product container\033[0m" docker build \ --build-arg BUILDER_UID="$(id -u)" \ - --file $repo/.ci/Dockerfile \ + --file $repo/.buildkite/Dockerfile \ --tag ${product} \ . diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f38fdc108..6f6684020 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: python -m pip install nox - name: Run Tests shell: bash - run: .ci/run-nox.sh + run: .buildkite/run-nox.sh env: PYTHON_VERSION: ${{ matrix.python-version }} NOX_SESSION: ${{ matrix.nox-session }} diff --git a/.github/workflows/unified-release.yml b/.github/workflows/unified-release.yml index d2f7e8442..ac049a732 100644 --- a/.github/workflows/unified-release.yml +++ b/.github/workflows/unified-release.yml @@ -22,4 +22,4 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: "Assemble ${{ env.STACK_VERSION }}" - run: "./.ci/make.sh assemble ${{ env.STACK_VERSION }}" + run: "./.buildkite/make.sh assemble ${{ env.STACK_VERSION }}" diff --git a/test_elasticsearch/utils.py b/test_elasticsearch/utils.py index a2b44afe5..f4f8cc885 100644 --- a/test_elasticsearch/utils.py +++ b/test_elasticsearch/utils.py @@ -30,7 +30,7 @@ ) SOURCE_DIR = Path(__file__).absolute().parent.parent -CA_CERTS = str(SOURCE_DIR / ".ci/certs/ca.crt") +CA_CERTS = str(SOURCE_DIR / ".buildkite/certs/ca.crt") def es_url() -> str: diff --git a/utils/bump-version.py b/utils/bump-version.py index e91d3bdcb..44fc78e4e 100644 --- a/utils/bump-version.py +++ b/utils/bump-version.py @@ -70,9 +70,9 @@ def main(): # These values should always be the 'major.minor-SNAPSHOT' major_minor_version = ".".join(python_version.split(".")[:2]) find_and_replace( - path=SOURCE_DIR / ".ci/test-matrix.yml", + path=SOURCE_DIR / ".buildkite/pipeline.yml", pattern=r'STACK_VERSION:\s+\- "[0-9]+[0-9\.]*[0-9](?:\-SNAPSHOT)?"', - replace=f'STACK_VERSION:\n - "{major_minor_version}.0-SNAPSHOT"', + replace=f'STACK_VERSION:\n - "{major_minor_version}.0-SNAPSHOT"', ) find_and_replace( path=SOURCE_DIR / ".github/workflows/unified-release.yml", From e70b546fa5c83bfa5837fafb7856b196333e3896 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Fri, 22 Sep 2023 13:24:07 -0500 Subject: [PATCH 5/8] Linter bug --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index a7abda2fb..a5e4d0ffd 100644 --- a/noxfile.py +++ b/noxfile.py @@ -36,7 +36,7 @@ def test(session): session.install("-r", "dev-requirements.txt") python_version = tuple(int(x) for x in session.python.split(".")) - job_id = os.environ.get('BUILDKITE_JOB_ID', None) + job_id = os.environ.get("BUILDKITE_JOB_ID", None) if job_id is not None: junit_xml = os.path.join(SOURCE_DIR, "junit", f"{job_id}-junit.xml") else: From bc74a8e016215c9b5c7505cbc8c49ce3a6141d0d Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Fri, 22 Sep 2023 13:25:32 -0500 Subject: [PATCH 6/8] Fix misreferenced make.sh file --- .github/workflows/unified-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unified-release.yml b/.github/workflows/unified-release.yml index ac049a732..d2f7e8442 100644 --- a/.github/workflows/unified-release.yml +++ b/.github/workflows/unified-release.yml @@ -22,4 +22,4 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: "Assemble ${{ env.STACK_VERSION }}" - run: "./.buildkite/make.sh assemble ${{ env.STACK_VERSION }}" + run: "./.ci/make.sh assemble ${{ env.STACK_VERSION }}" From 1a70b2837ae8037771b772c5bbe5b51b536b2e6d Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Fri, 22 Sep 2023 13:35:07 -0500 Subject: [PATCH 7/8] Update vm.max_map_count in Buildkite jobs --- .buildkite/run-elasticsearch.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.buildkite/run-elasticsearch.sh b/.buildkite/run-elasticsearch.sh index 7f6e77759..1ca3eb2e0 100755 --- a/.buildkite/run-elasticsearch.sh +++ b/.buildkite/run-elasticsearch.sh @@ -31,6 +31,10 @@ cleanup_node $es_node_name master_node_name=${es_node_name} cluster_name=${moniker}${suffix} +if [[ "$BUILDKITE" == "true" ]]; then + sudo sysctl -w vm.max_map_count=262144 +fi + declare -a volumes environment=($(cat <<-END --env ELASTIC_PASSWORD=$elastic_password From 2af321c1e0afd229798df77b72ca2baa2ee9cc02 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Fri, 22 Sep 2023 13:50:14 -0500 Subject: [PATCH 8/8] Clean up Docker container setup --- .buildkite/Dockerfile | 21 ++++----------------- .buildkite/run-repository.sh | 4 ---- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/.buildkite/Dockerfile b/.buildkite/Dockerfile index 569de2e05..03e950ffd 100644 --- a/.buildkite/Dockerfile +++ b/.buildkite/Dockerfile @@ -1,26 +1,13 @@ ARG PYTHON_VERSION=3.8 FROM python:${PYTHON_VERSION} -# Default UID/GID to 1000 -# it can be overridden at build time -ARG BUILDER_UID=1000 -ARG BUILDER_GID=1000 -ENV BUILDER_USER elastic -ENV BUILDER_GROUP elastic -ENV PATH="${PATH}:/var/lib/elastic/.local/bin" - -# Create user -RUN groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP} \ - && useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GROUP} -d /var/lib/elastic -m elastic 1>/dev/null 2>/dev/null \ - && mkdir -p /code/elasticsearch-py && mkdir /code/elasticsearch-py/build \ - && chown -R ${BUILDER_USER}:${BUILDER_GROUP} /code/ -COPY --chown=$BUILDER_USER:$BUILDER_GROUP . . WORKDIR /code/elasticsearch-py -USER ${BUILDER_USER}:${BUILDER_GROUP} + COPY dev-requirements.txt . RUN python -m pip install \ -U --no-cache-dir \ --disable-pip-version-check \ - nox -rdev-requirements.txt -COPY --chown=$BUILDER_USER:$BUILDER_GROUP . . + -r dev-requirements.txt + +COPY . . RUN python -m pip install -U -e . diff --git a/.buildkite/run-repository.sh b/.buildkite/run-repository.sh index 5f204901b..e0c24f23d 100755 --- a/.buildkite/run-repository.sh +++ b/.buildkite/run-repository.sh @@ -27,15 +27,12 @@ docker build \ --file .buildkite/Dockerfile \ --tag elastic/elasticsearch-py \ --build-arg "PYTHON_VERSION=$PYTHON_VERSION" \ - --build-arg "BUILDER_UID=$(id -u)" \ - --build-arg "BUILDER_GID=$(id -g)" \ . echo "--- :docker: :python: Run elastic/elasticsearch-py container" mkdir -p "$(pwd)/junit" docker run \ - -u "$(id -u):$(id -g)" \ --network="$network_name" \ -e STACK_VERSION \ -e "ELASTICSEARCH_URL=$elasticsearch_url" \ @@ -45,5 +42,4 @@ docker run \ --name elasticsearch-py \ --rm \ elastic/elasticsearch-py \ - bash -c "nox -s test-$PYTHON_VERSION; [ -f ./junit/$BUILDKITE_JOB_ID-junit.xml ] && mv ./junit/$BUILDKITE_JOB_ID-junit.xml /junit || echo 'No JUnit artifact found'"