Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

chore: reorganize make tasks #149

Merged
merged 4 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions .github/workflows/auto-commit-client-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,21 @@ jobs:
java-version: '11'
distribution: 'temurin'
cache: maven

- name: Commit to branch if client is updated after executing make.

- name: Apply spec patches
id: patch
run: |
make patch
git add spec/oas3.patched
echo `git commit -m 'sync: apply patches to existing spec'`

- name: Generate code
id: generate
run: |
make generate
git add equinix-openapi-metal
echo `git commit -m 'sync: generate client with patched spec'`

- name: Push changes
run: |
git fetch
echo -e "\nThis is executing for branch: ${GITHUB_REF_NAME}."
git checkout ${GITHUB_REF_NAME}
make docker_run
echo -e "Make execution completed."
git add spec/oas3.patched/.
git add spec/oas3.stitched/.
git add equinix-openapi-metal/.
echo -e "\nGit status:"
echo `git status`
cdate=`date`
cmsg="Auto commit generated client changes - $cdate"
echo -e "\nCommit message created : $cmsg"
echo -e "\nCommitting if there are files to update in client dir:"
echo `git commit -m "$cmsg"`
echo `git push`
4 changes: 2 additions & 2 deletions .github/workflows/run-device-functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
cache: maven

- name: Run equinix metal-java make
run: make docker_run
run: make generate

- name: Install equinix client
working-directory: ./equinix-openapi-metal
Expand All @@ -61,4 +61,4 @@ jobs:
run: mvn clean test -Dtest=com.equinix.test.functional.TestDeviceOperator.java --file pom.xml
env:
FUNCTIONAL_TEST_TOKEN: ${{ secrets.token }}
FUNCTIONAL_TEST_PROJECT_UUID: ${{ secrets.project_uuid }}
FUNCTIONAL_TEST_PROJECT_UUID: ${{ secrets.project_uuid }}
4 changes: 2 additions & 2 deletions .github/workflows/run-metalgateway-functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
cache: maven

- name: Run equinix metal-java make
run: make docker_run
run: make generate

- name: Install equinix client
working-directory: ./equinix-openapi-metal
Expand All @@ -61,4 +61,4 @@ jobs:
run: mvn clean test -Dtest=com.equinix.test.functional.TestMetalGatewayOperator.java --file pom.xml
env:
FUNCTIONAL_TEST_TOKEN: ${{ secrets.token }}
FUNCTIONAL_TEST_PROJECT_UUID: ${{ secrets.project_uuid }}
FUNCTIONAL_TEST_PROJECT_UUID: ${{ secrets.project_uuid }}
2 changes: 1 addition & 1 deletion .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
id: generate
if: ${{ always() && steps.patch.conclusion == 'success' }}
run: |
make docker_generate move-workflow build_client
make generate
git add equinix-openapi-metal
echo `git commit -m 'sync: generate client with patched ${{ steps.date.outputs.date }} spec'`
- name: Create Pull Request
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: docker_run docker_generate
.PHONY: all clean patch pull generate codegen move-workflow build_client

CURRENT_UID := $(shell id -u)
CURRENT_GID := $(shell id -g)
Expand Down Expand Up @@ -38,12 +38,14 @@ SPEC_FETCHED_PATCHES=patches/spec.fetched.json
OPENAPI_CODEGEN_IMAGE=openapitools/openapi-generator-cli:v6.6.0
DOCKER_OPENAPI=${CRI} run --rm -u ${CURRENT_UID}:${CURRENT_GID} -v $(CURDIR):/local ${OPENAPI_CODEGEN_IMAGE}

docker_run: clean patch pull docker_generate move-workflow build_client
all: pull fetch patch generate

generate: clean codegen move-workflow build_client

pull:
${CRI} pull ${OPENAPI_CODEGEN_IMAGE}

docker_generate:
codegen:
${DOCKER_OPENAPI} generate \
-i /local/${PATCHED_SPEC_ENTRY_POINT} \
-g java \
Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ java -classpath "equinix-openapi-metal/target/equinix-openapi-metal-1.0.0.jar:eq

Using openapi generator v3 docker image :
```
make docker_run
make generate
```

Note : docker pulls latest version of openapi generator.

## Contribution guidelines
### Patching oas3.0 spec
1. Make changes in ``spec/oas3.patched/`` dir.
Expand All @@ -52,8 +50,7 @@ Note : docker pulls latest version of openapi generator.
cd ..
```
3. ``patchfilename`` should be in format: ``<patch_index>-<short_patch_decription_or_identifier>.patch``
4. Run ``make docker_run`` to reapply the changes to oas spec.
5. Before pushing changes, commit ``metal-java/spec/oas3.stitched/oas3.stitched.metal.yaml`` along with the patch file.
4. Run ``make patch`` to reapply the changes to oas spec.

### Adding complex workflows
Complex workflows requiring multiple granular, autogenerated apis can be implemented as part of Operator classes. These classes are included in the path ``equinix-openapi-metal/src/main/java/com/equinix/workflow`` when building the sdk. An example use case for operator implementation can be for APIs requiring polling logic to fetch updated resource state.
Expand All @@ -76,4 +73,4 @@ Complex workflows requiring multiple granular, autogenerated apis can be impleme
3. Run command set to ```clean test -Dtest=com.equinix.test.functional.TestDeviceOperator.java --file pom.xml```
4. If using environment variables, they can be added in Java options.
4. Alternatively, you can do step iii through terminal directly.
4. For every new functional test, a separate github workflow .yaml should be defined inside ```.github/workflows```. These can be run from Github's actions UI directly. Check existing workflow definitions for reference.
4. For every new functional test, a separate github workflow .yaml should be defined inside ```.github/workflows```. These can be run from Github's actions UI directly. Check existing workflow definitions for reference.