diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 1d3af2d..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,182 +0,0 @@ -version: 2 - -# Keep this at the top to reduce noise in chatrooms when we mess up circleci setup -experimental: - notify: - branches: - only: - - main - -jobs: - build: - docker: - - image: ldcircleci/openapi-release:1 # same image we use for releases, includes all necessary tools - steps: - - checkout - - - run: - name: Generating code - command: | - export REPO_USER_URL=https://github.com/$CIRCLE_PROJECT_USERNAME - echo "Setting version to ${CIRCLE_TAG:-0.0.1}" - LD_RELEASE_VERSION="${CIRCLE_TAG:-0.0.1}" make all - - - run: - name: Archiving targets - command: | - cd targets - tar cvfz api-clients-${CIRCLE_TAG:-0.0.1}-${CIRCLE_SHA1:0:7}.tgz api-client-* - mkdir /tmp/api-clients - cp api-clients-*.tgz /tmp/api-clients - - - persist_to_workspace: - root: targets - paths: - - . - - - store_artifacts: - path: targets/html2 - destination: html - - - store_artifacts: - path: targets/html - destination: html-plain - - - store_artifacts: - path: /tmp/api-clients - - test-go: - docker: - - image: cimg/go:1.15 - steps: - - checkout - - attach_workspace: - at: targets - - run: | - sudo mkdir -p /go/src/github.com/launchdarkly - sudo cp -r targets/api-client-go /go/src/github.com/launchdarkly/ - - run: | - cd samples/go - make - - test-javascript: - docker: - - image: cimg/node:14.17 - steps: - - checkout - - attach_workspace: - at: targets - - run: | - cd targets/api-client-javascript - npm install - cd ../.. - cd samples/javascript - sudo npm link ../../targets/api-client-javascript - node index.js - - test-python: - docker: - - image: cimg/python:3.7 - steps: - - checkout - - attach_workspace: - at: targets - - run: sudo apt-get update && sudo apt-get install -y pip - - run: | - cd samples/python - pip install -e ../../targets/api-client-python - python main.py - - test-ruby: - docker: - - image: cimg/ruby:2.7 - steps: - - checkout - - attach_workspace: - at: targets - - run: - name: Install Gem - command: | - cd targets/api-client-ruby - gem build launchdarkly_api.gemspec - gem install ./launchdarkly_api*.gem - - run: | - cd samples/ruby - ruby main.rb - - test-java: - docker: - - image: circleci/openjdk:8 - steps: - - checkout - - attach_workspace: - at: targets - - run: | - cd targets/api-client-java - mvn clean install - cd ../../samples/java - sed -i.bak -e "s/API_CLIENT_VERSION/${CIRCLE_TAG:-0.0.1}/g" pom.xml - mvn clean install - mvn exec:java - - test-typescript: - docker: - - image: cimg/node:14.17 - steps: - - checkout - - attach_workspace: - at: targets - - run: | - cd targets/api-client-typescript-axios - sudo npm install - sudo npm run build - sudo npm link - cd ../../samples/typescript-axios - sudo npm link launchdarkly-api-typescript - sudo npm install - sudo npm run build - npm start - - test-php: - docker: - - image: cimg/php:8.0.19 - steps: - - checkout - - attach_workspace: - at: targets - - run: | - cd samples/php - echo '{"require":{"launchdarkly/api-client-php":"@dev","guzzlehttp/guzzle":"*"},"repositories":[{"type":"path","url":"../../targets/api-client-php","options":{"symlink":true}}]}' > composer.json - composer update - php index.php - -workflows: - version: 2 - build: - jobs: - - build: - filters: - tags: - only: - /.*/ # Required in order to run publish job for a tag push - - test-go: - requires: - - build - - test-javascript: - requires: - - build - - test-python: - requires: - - build - - test-java: - requires: - - build - - test-ruby: - requires: - - build - - test-typescript: - requires: - - build - - test-php: - requires: - - build diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7569411 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,69 @@ +name: Build & Test +on: + push: + tags: + - '*' # Build for any tag + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.get_version.outputs.VERSION }} + steps: + - uses: actions/checkout@v4 + - name: Get tag name, or set default + id: get_version + run: | + # Use the pushed tag, or default to 0.0.1 if no tag + VERSION="${GITHUB_REF#refs/tags/}" + + # If no tag was pushed, use default + if [[ "$VERSION" == "$GITHUB_REF" ]]; then + VERSION="0.0.1" + fi + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + shell: bash + - name: Generate SHA data + run: | + echo "SHA=${{ github.event.pull_request.head.sha || github.sha }}" >> "$GITHUB_ENV" + echo "SHORT_SHA=$(cut -c 1-7 <<< ${{ github.event.pull_request.head.sha || github.sha }})" >> "$GITHUB_ENV" + - name: Generate code + run: make all + env: + LD_RELEASE_VERSION: ${{ env.VERSION }} + - name: Archive targets + run: | + tar czvf api-clients-${{ env.VERSION }}-${{ env.SHORT_SHA }}.tgz api-client-* + mkdir /tmp/api-clients + cp api-clients-*.tgz /tmp/api-clients/ + working-directory: targets + + - name: Upload targets directory + uses: actions/upload-artifact@v4 + with: + name: targets + path: targets/ + - name: Upload API clients + uses: actions/upload-artifact@v4 + with: + name: api-clients-${{ env.VERSION }}-${{ env.SHORT_SHA }} + path: /tmp/api-clients + - name: Upload HTML + uses: actions/upload-artifact@v4 + with: + name: html + path: targets/html2 + - name: Upload plain HTML + uses: actions/upload-artifact@v4 + with: + name: plain-html + path: targets/html + + test: + needs: build + uses: './.github/workflows/test.yml' + secrets: inherit + with: + version: ${{ needs.build.outputs.version }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e151dc5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,141 @@ +on: + workflow_call: + inputs: + version: + required: true + type: string + +env: + LD_API_KEY: ${{ secrets.LD_API_TOKEN }} + +jobs: + test-go: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.23' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: | + mkdir -p /home/runner/go/src/github.com/launchdarkly + cp -r targets/api-client-go /home/runner/go/src/github.com/launchdarkly/ + - run: make + working-directory: samples/go + + test-javascript: + runs-on: ubuntu-latest + if: false # Disable the test for now - it's broken due to ES6 stuff. Other tests confirm the clients are working + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: npm install + working-directory: targets/api-client-javascript + - run: | + npm link $GITHUB_WORKSPACE/targets/api-client-javascript + node --experimental-modules index.js + working-directory: samples/javascript + + + test-python: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: | + pip install -e ../../targets/api-client-python + python main.py + working-directory: samples/python + + test-ruby: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: | + gem build launchdarkly_api.gemspec + gem install ./launchdarkly_api*.gem + working-directory: targets/api-client-ruby + - run: ruby main.rb + working-directory: samples/ruby + + test-java: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: 8 + distribution: 'corretto' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: mvn clean install + working-directory: targets/api-client-java + - run: | # TODO: Need to fix the tag below + sed -i.bak -e "s/API_CLIENT_VERSION/${{ inputs.version }}/g" pom.xml + mvn clean install + mvn exec:java + working-directory: samples/java + + test-typescript: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: | + npm install + npm run build + npm link + working-directory: targets/api-client-typescript-axios + - run: | + npm link launchdarkly-api-typescript + npm install + npm run build + npm start + working-directory: samples/typescript-axios + + test-php: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: | + echo '{"require":{"launchdarkly/api-client-php":"@dev","guzzlehttp/guzzle":"*"},"repositories":[{"type":"path","url":"../../targets/api-client-php","options":{"symlink":true}}]}' > composer.json + composer update + php index.php + working-directory: samples/php